Advertisements
Advertisements
प्रश्न
Write a function to print the table of a given number. The number has to be entered by the user.
उत्तर
Program:
#Program to print the table of a number
num = int(input("Enter the number to display its table: "))
print("Table: ");
for a in range(1,11):
print(num," × ",a," = ",(num*a))
OUTPUT:
Enter the number to display its table: 5
Table:
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
APPEARS IN
संबंधित प्रश्न
What is the purpose of the range() function? Give one example.
Find the output of the following program segment:
for i in range(20,30,2):
print(i)
Find the output of the following program segment:
country = 'INDIA'
for i in country:
print (i)
Find the output of the following program segment:
for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y)
Write a program that prints the minimum and maximum of five numbers entered by the user.
Write a program to generate the sequence: –5, 10, –15, 20, –25….. up to n, where n is an integer input by the user.
Write a program to find the sum of 1 + 1/8 + 1/27......1/n3, where n is the number input by the user.
Write a program to print the following pattern:
1 2 1 2 3 2 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5 |
Write a program to print the following pattern:
1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 |
Write a program to print the following pattern:
* * * * * * * * |