Objective
Develop a Python program to ask the user for a number and display its multiplication table, like this:
Please enter a number:
5
The multiplication table for 5 is:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
...
5 x 10 = 50
Example Python Exercise
Show Python Code
# Prompt the user to enter a number
num = int(input("Please enter a number: "))
# Display the multiplication table for the entered number
print(f"\nThe multiplication table for {num} is:")
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
Output
Please enter a number:
5
The multiplication table for 5 is:
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
Share this Python Exercise
Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.
In this exercise, you will develop a Python program that calculates and displays the average of four numbers provided by the user. This task allows you ...
In this exercise, you will develop a Python program to prompt the user for three numbers (a, b, c) and display the result of the expressions (a + b) * c...
In this exercise, you will develop a Python program to prompt the user for their age (e.g., 20) and respond with a message like "You look younger than age...
In this exercise, you will develop a Python program to prompt the user for a number and display it four times in a row, separated by spaces, and then four time...
In this exercise, you will develop a Python program to prompt the user for a number and then display a rectangle 3 columns wide and 5 rows tall using that d...
In this exercise, you will develop a Python program that asks the user for a temperature in Celsius and converts it to both Kelvin and Fahrenheit...