Python - For LoopWhich of the following is the correct syntax for a for loop in Python?Afor (i=0; i<5; i++) print(i)Bfor i to range(5) print(i)Cfor i in range(5): print(i)Dforeach i in range(5): print(i)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall Python for loop syntaxPython uses 'for variable in sequence:' followed by indented code. 'for i in range(5): print(i)' matches; others use wrong keywords or styles.Final Answer:for i in range(5): print(i) -> Option CQuick Check:Python for loop = for variable in sequence: [OK]Quick Trick: Use 'for variable in sequence:' syntax in Python [OK]Common Mistakes:MISTAKESUsing 'to' instead of 'in'Using C-style for loop syntaxUsing 'foreach' which is not Python
Master "For Loop" in Python9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Python Quizzes Conditional Statements - Logical operators in conditions - Quiz 4medium Data Types as Values - Numeric values (int and float behavior) - Quiz 14medium Data Types as Values - Boolean values (True and False) - Quiz 13medium Input and Output - print() parameters and formatting - Quiz 13medium Loop Control - Continue statement behavior - Quiz 11easy Loop Control - Continue statement behavior - Quiz 2easy Operators and Expression Evaluation - Assignment and augmented assignment - Quiz 6medium Operators and Expression Evaluation - Comparison operators - Quiz 9hard Python Basics and Execution Environment - Why Python is easy to learn - Quiz 15hard Variables and Dynamic Typing - Naming rules and conventions - Quiz 3easy