Exercise
Multiple Times Tables (Using While)
Objective
Develop a Python program that displays multiplication tables from 2 to 6 using nested "while" loops.
Example Python Exercise
Show Python Code
# Initialize the outer loop variable for the multiplication tables from 2 to 6
i = 2
# Use a while loop for the outer loop
while i <= 6:
print(f"\nMultiplication table for {i}:")
# Initialize the inner loop variable for the multipliers from 1 to 10
j = 1
# Use a while loop for the inner loop
while j <= 10:
print(f"{i} x {j} = {i * j}")
j += 1
i += 1
Output
Multiplication table for 2:
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
Multiplication table for 3:
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
Multiplication table for 4:
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36
4 x 10 = 40
Multiplication table for 5:
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
Multiplication table for 6:
6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60
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 prompts the user to enter a number and a width, and then displays a square of that width using ...
In this exercise, you will develop a Python program that writes the even numbers from 10 to 20, both inclusive, except 16. The program will implement three different methods...
In this Python exercise, you will develop a program that prompts the user to input a number, width, and height and displays a rectangle of the specified...
This Python program allows the user to input two numbers and displays all the numbers between them (inclusive) three times using different types of loops: "for"...
This Python program demonstrates how to calculate the number of digits in a positive integer by repeatedly dividing the number by 10. If the user enters a n...
This Python program prompts the user to input a symbol and a width, then displays a hollow square with the specified width. The square's outer border is...