Read n and print its multiplication table from 1 to 10, one line each, in the form n x i = result.
What to build
A loop that prints one line for each value.
Requirements
- Read
n. - Print ten lines in the form
n x i = result.
Input
One whole number n from 1 to 1000.
Output
Ten lines, from n x 1 to n x 10.
Constraints
n is from 1 to 1000.
Example
Input:
3
Output:
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
Why it works
The loop variable changes on each pass, so the same print line produces a different row each time.
Examples
Example 1 · Input
3
Expected output
3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30
Example 2 · Input
1
Expected output
1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 1 x 5 = 5 1 x 6 = 6 1 x 7 = 7 1 x 8 = 8 1 x 9 = 9 1 x 10 = 10
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
print(n, "x", i, "=", n * i) puts single spaces between the parts.
Solution
Show one correct solution (try it yourself first)
n = int(input())
for i in range(1, 11):
print(n, "x", i, "=", n * i)