Robotics & Artificial Intelligence
Write a Python code to display the Mathematical Tables from 5 to 10. Each Mathematical Table should run for 10 iterations as shown in the given format:
Sample Output: Table of 5
5*1 = 5
5*2 = 10
...............
...............
5*10 = 50
Answer
for i in range(5, 11):
print("Table of", i)
for j in range(1, 11):
print(i, "*", j, "=", i*j)
print()Output
Table of 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
Table of 6
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60
Table of 7
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70
Table of 8
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80
Table of 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
Table of 10
10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100
Related Questions
Write a program to input a number. Check and display whether it is a Niven Number or not. (A number is said to be Niven when it is divisible by the sum of its digits).
Sample Input: 126
Sum of its digits = 1 + 2 + 6 = 9 and 126 is divisible by 9.
Write a program to input a number and display the new number after reversing the digits.
Sample Input: 467
Sample Output: 764
Write a Python code to accept any 20 numbers and display only those numbers which are prime.
[Hint: A number is said to be prime, if it is divisible by 1 and the number itself.]
A number is said to be 'Happy number' if eventual sum of the square of its digits results in 1. Write a Python code to input a number and check whether it is a Happy Number or not.
Sample Input: 31
Sample Output: 31 = 32 + 12 = 10 = 12 + 0 = 1
Hence, it is a Happy Number