Bird
0
0

You want to print a multiplication table from 1 to 3 using nested loops. Which code correctly does this?

hard📝 Application Q8 of 15
Python - For Loop
You want to print a multiplication table from 1 to 3 using nested loops. Which code correctly does this?
Afor i in range(1,4):\nfor j in range(1,4):\n print(i*j)
Bfor i in range(3):\n for j in range(3):\n print(i+j, end=' ')\n print()
Cfor i in range(1,4):\n for j in range(1,4):\n print(i*j, end=' ')\n print()
Dfor i in range(1,4):\n for j in range(1,4):\n print(i*j, end=' ')
Step-by-Step Solution
Solution:
  1. Step 1: Check ranges for 1 to 3

    range(1,4) correctly includes 1,2,3.
  2. Step 2: Verify nested loop and print formatting

    Inner loop prints product with space, outer loop prints newline after each row.
  3. Final Answer:

    for i in range(1,4):\n for j in range(1,4):\n print(i*j, end=' ')\n print() -> Option C
  4. Quick Check:

    Correct ranges and print formatting for multiplication table [OK]
Quick Trick: Use range(1,4) and print with end=' ' and print() for new line [OK]
Common Mistakes:
MISTAKES
  • Using wrong ranges starting at 0
  • Incorrect indentation
  • Missing print() for new line

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes