Example
Text Formatting with f-strings
F-strings are a modern way to format text in Python. Insert variables directly into text.
Showing 1–10 of 12
Example
F-strings are a modern way to format text in Python. Insert variables directly into text.
Challenge
Build eng-2_2026-03-14.csv from a sensor ID and a date, then turn a name like Star Tracker A into a safe file name, and put the file in a folder of its own.
Challenge
…and a fuel fraction as a percentage, using format specs in f-strings.
Challenge
Turn the day's subsystem status into a fixed-width report for the shift handover, with aligned columns and a totals line, then save the same data as a CSV file with csv.DictWriter for the spreadsheet…
Challenge
Move the mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.
Challenge
Extend the parser from "Parse a telemetry line" to read three readings from a multi-line feed, print each as one row, then turn them into a report with a header and aligned columns.
Challenge
Print an alert between two 30-character borders from a single f-string with \n, then add more lines and centre the title in the border.
Challenge
Print systems and their states in aligned columns with width specifiers like {name:
Challenge
Print a JSON-style status message full of double quotes and an apostrophe exactly, then build it with an f-string that needs literal curly braces.
Challenge
Turn values into a log line like [T+00:12:05] INFO Engines nominal with an f-string, then build the timestamp from numbers with zero padding.