I have been working with python for about a month now, but today I came across a problem I have yet to see; multiplication tables. I have absolutely no idea where to start or how to begin to format said table. The problem will be listed below, and if anyone can help getting me started I would be greatly thankful.
-Tyler
Write a program to display a multiplication table for integers in a given range. The program should accept two integers as input representing the minimum and maximum values the table should contain. The program should then print a table representing the multiplication table for integers in the given range. Note that you need to define two functions in this program. First function get_integers() gets inputs from the user; it takes no values, and returns two integers (the second one is larger than the first one). Second function display_table() displays the multiplication table, which takes two integers as its parameters. See a sample table below (the user types in 3 and 8):
| 3 4 5 6 7 8
-----------------------------------
3| 9 12 15 18 21 24
-----------------------------------
4| 12 16 20 24 28 32
-----------------------------------
5| 15 20 25 30 35 40
-----------------------------------
6| 18 24 30 36 42 48
-----------------------------------
7| 21 28 35 42 49 56
-----------------------------------
8| 24 32 40 48 56 64
Note for this program, the easiest way to print out the table with the numbers aligned as the one shown above is to use string formatting. The syntax of string formatting is: format % values. For examples, "%4d" % 3 gives ' 3' (notice the 3 spaces before number 3), and "%4d%4d" % (3, 4) gives ' 3 4'. In these two examples, %4d ('%' character marks the start of the specifier) tells the program to convert an integer (what d stands for) into a string by inserting spaces before the number to make a string with length of 4 (what 4 stands for).