Python Exercise: Create the multiplication table of a number
Python Conditional: Exercise - 43 with Solution
Write a Python program to create the multiplication table (from 1 to 10) of a number.
# Prompt the user to input a number and convert it to an integer, assigning it to the variable 'n' n = int(input("Input a number: ")) # Use a for loop to iterate 10 times, starting from 1 up to 10 (excluding 11) for i in range(1, 11): # Print the multiplication table for the entered number 'n' by multiplying it with each iteration 'i' print(n, 'x', i, '=', n * i)
Input a number: 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
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to calculate the sum and average of n integer numbers (input from the user). Input 0 to finish.
Next: Write a Python program to construct the following pattern, using a nested loop number.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join