Times Table - Python Programming Exercise

In this exercise, you will develop a Python program that prompts the user to input two numbers and then displays the results of their addition, subtraction, multiplication, division, and remainder. The program will process these operations and display the results in a clear, readable format. This task will help you practice using arithmetic operations in Python and displaying the results with the print function. By completing this exercise, you will deepen your understanding of Python syntax and how to handle multiple mathematical operations in a single program. You will also improve your skills in working with user input and performing dynamic calculations, which are essential for creating interactive Python applications. This foundational knowledge will serve you well as you continue to explore more advanced programming concepts in Python.

 Category

Your First Steps in Python

 Exercise

Times Table

 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

 Copy 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

 More Python Programming Exercises of Your First Steps in Python

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.

  •  Calculating the Mean

    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 ...

  •  Comparative Calculations

    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...

  •  Calculating Years

    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...

  •  Data Presentation Styles

    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...

  •  Quadrilateral Dimensions

    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...

  •  Conversion

    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...