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 19
Example
F-strings are a modern way to format text in Python. Insert variables directly into text.
Quiz
…on quotes, escape characters, sep, end, flush and f-string formatting, with instant answers.
Article Python Fundamentals
…telescope_temp_3) Multiple values display in formatted way Some systems provide timestamps with measured data. It's helpful to see the temperature value with the last measured date and time. This…
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
Print one cargo manifest line for every record in a list of dicts, reading each field by key, then add up the masses in the same loop for a total line.
Challenge
Store the Perseverance landing site as a (lat, lon) tuple, unpack it into two variables in one line and print both to four decimals, then show it the way maps do, with N, S, E and W.
Challenge
Unpack an (id, item, mass_kg) tuple into three named variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.
Challenge
Predict 0.1 + 0.2, see the 0.30000000000000004 that every programmer meets once, then round it for display the way fuel gauges and dashboards do.
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: