Python - For LoopYou 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=' ')Check Answer
Step-by-Step SolutionSolution:Step 1: Check ranges for 1 to 3range(1,4) correctly includes 1,2,3.Step 2: Verify nested loop and print formattingInner loop prints product with space, outer loop prints newline after each row.Final Answer:for i in range(1,4):\n for j in range(1,4):\n print(i*j, end=' ')\n print() -> Option CQuick 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:MISTAKESUsing wrong ranges starting at 0Incorrect indentationMissing print() for new line
Master "For Loop" in Python9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Python Quizzes Input and Output - Formatting using format() method - Quiz 7medium Input and Output - Formatting using format() method - Quiz 1easy Loop Control - Why loop control is required - Quiz 13medium Python Basics and Execution Environment - Python Block Structure and Indentation - Quiz 12easy Python Basics and Execution Environment - Comments in Python - Quiz 2easy Variables and Dynamic Typing - Type checking using type() - Quiz 7medium Variables and Dynamic Typing - How variable type changes at runtime - Quiz 3easy Variables and Dynamic Typing - Dynamic typing in Python - Quiz 1easy While Loop - Nested while loops - Quiz 8hard While Loop - Why while loop is needed - Quiz 2easy