Table of Contents

, , , , , , , , ,

About the Club

Python Club Topics - Exercise: Multiplication table

Exercise: Multiplication Table

  1. Output: Display the multiplication table for a given number up to 10
  2. What you learn from the example:
    1. Code is done in order
    2. Comments used to describe the code
    3. Assign values to variables
    4. Use a for loop
    5. Print to the screen

Solution

[1] code:python show
# Multiplication table (from 1 to 10) in Python

num = 12

# To take input from the user
# num = int(input(“Display multiplication table of? ”))

# Iterate 10 times from i = 1 to 10
for i in range(1, 11):
   print(num, 'x', i, '=', num*i)