Beginner Python Exercises

Multiplication Table in Python

A counted loop can generate predictable formatted rows.

What is Multiplication Table?

A counted loop can generate predictable formatted rows.

Print the first five multiples of a number.

When should you use it?

  • Learn Python syntax through a practical example.
  • Build a foundation for larger programming problems.
  • Test an idea quickly without a local setup.

Example code

Run code →
main.py
number = 7
# Generate one formatted row for each multiplier.
for multiplier in range(1, 6):
    print(f"{number} x {multiplier} = {number * multiplier}")

Expected output

7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35

How it works

Each iteration supplies one multiplier and calculates its product.

Change the values and run the program in the CodeUtility online Python compiler without installing Python locally.

Practice exercises

Modify the runnable example with the exercises below to build understanding beyond copying the result.

  1. Change the input and predict the output before running.
  2. Handle empty or invalid input.
  3. Wrap the logic in a function and add more test cases.
Run in Python IDE →