Multiplication Table
·207 words·1 min
Hello, do you want to make a timetable of a number of your choice?
Well, you can use my python code.
Here’s my python code and how you do it:
# Author: Koder T.
# 2023-11-02
num = int(input("Enter a number between 1 and 12: "))
# check that 1 <= num <= 12
while num < 1 or num > 12:
print(f"{num} is not between 1 and 12.")
num = int(input("Please enter a new number: "))
print("--------------------------------")
for i in range(1, 13, 1):
print(f" {num} x {i:2d} = {num * i:2d}")
print("--------------------------------")
Copy the code above and save it to a file called timetable.py.
Then you can run this program. :)
python3 timetable.py
Enter a number between 1 and 12: 5
--------------------------------
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
5 x 11 = 55
5 x 12 = 60
--------------------------------
Dad joke:
The program will be happy if you enter a number between 1 and 12.
Comment by Koder T:
Hahaha very funny