Python Quest

Track 7 · Lesson 6 of 11

Formatting text reports

Produce aligned tables and tidy reports with format specifications, str.format(), multi-line strings and the textwrap module.

About 45 minIntermediate4 exercises

You will be able to

  • Write format specifications with fill, alignment, width, precision, sign and thousands separators
  • Compute column widths from the data and build an aligned text table
  • Use str.format() templates with numbered and named fields, and say when they beat f-strings
  • Write multi-line strings and wrap, indent and dedent paragraphs with textwrap

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.