108. Python Program to Print a Multiplication Table in Columns
MediumFormatting
Overview
Combine a for loop with f-string widths to print neat columns.
Problem Statement
Read a whole number n and print its multiplication table from 1 to 10. Make the columns line up: the number after x gets a width of 2, and the result gets a width of 3, both pushed to the right. For example, for 7:
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One whole number from 1 to 99. Example:
7
Output
The output for that example is the table above, 10 lines. Spaces count, so look closely at where they are.
The tests try 4 different inputs.