Print Multiplication Table
Build a ten-row multiplication table from an entered integer. Students use range, a temporary result, and formatted output that labels every multiplication.
1# Take n as input2n = int(input("Enter a number: "))34# Print multiplication table5print(f"Multiplication table of {n}:")6for i in range(1, 11):7 result = n * i8 print(f"{n} × {i} = {result}")
Output
...
The sample abbreviates a longer result. The program prints the intervening values; it does not print these dots.
In this one
- Keep one operand fixed
- Calculate products in a loop
- Format labelled rows
How it works
- 1
Read n and print the heading.
- 2
Visit multipliers one through ten and compute n * i.
- 3
Print the labelled equation for each multiplier.
Edge cases
Does zero work?
Does zero work?
Yes. Every product is zero.
Can n be negative?
Can n be negative?
Yes. The ten multipliers are positive and the products carry n's sign.
What's going on
The entered number stays fixed while i runs from one through ten. Each iteration computes a new result using n * i.
The heading prints once before the loop. The row print then inserts n, i, and result into an f-string. With n equal to three, the row for i equal to four reads 3 × 4 = 12; this uses arithmetic multiplication, not repeated text.
Does zero work? Yes. Every product is zero.
Can n be negative? Yes. The ten multipliers are positive and the products carry n's sign.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
What changes on each row?
Pick an answer to check it.
Question 2
Does zero work?
Pick an answer to check it.
Questions people ask
Does zero work?
Yes. Every product is zero.
Can n be negative?
Yes. The ten multipliers are positive and the products carry n's sign.
What changes on each row?
i and result.
🔗Related Content
- 📖
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- 📝
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- 💻
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum