Multiplication Table¶
Use nested for
loops to generate a multiplication table, which should go all the way up to 12x9
(if you use tabs, 12x12
won’t fit on one screen).
It is hard to make the table look much nicer than the one below.
Don’t worry so much about the formatting of the table. The point is to practice nested loops.
Name the file mult_table.py
x | 1 2 3 4 5 6 7 8 9
==+==================================================================
1 | 1 2 3 4 5 6 7 8 9
2 | 2 4 6 8 10 12 14 16 18
3 | 3 6 9 12 15 18 21 24 27
4 | 4 8 12 16 20 24 28 32 36
5 | 5 10 15 20 25 30 35 40 45
6 | 6 12 18 24 30 36 42 48 54
7 | 7 14 21 28 35 42 49 56 63
8 | 8 16 24 32 40 48 56 64 72
9 | 9 18 27 36 45 54 63 72 81
10 | 10 20 30 40 50 60 70 80 90
11 | 11 22 33 44 55 66 77 88 99
12 | 12 24 36 48 60 72 84 96 108
©2021 Daniel Gallo
This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Adapted for Python from Graham Mitchell’s Programming By Doing