Challenge: Times Table
Completed
Read a number n and print its times table from 1 to 10.
Input
One whole number.
Output
10 lines like 7 x 1 = 7 … 7 x 10 = 70.
Example
Input
7
Output
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
Editor
Python
Hints
range(1, 11) gives 1 to 10.
An f-string makes the line easy: f"{n} x {i} = {n * i}"
Solution explanation
The loop variable i goes from 1 to 10 and we print one line per value.
Show solution
n = int(input())
for i in range(1, 11):
print(f"{n} x {i} = {n * i}")