Control Statements in Python — Python Technical Interview Questions & Answers
Control Statements in Python
Control Statements in Python
- Control statements decide which lines run and how often. Decision: if / elif / else. Loops: for / while. Jump helpers: break, continue, pass. Without them a script is only straight lines. Real programs choose a path, repeat work, and sometimes stop early.
- Viva overview: name the three groups with one keyword each. Then one tiny example — even/odd if, for over names, break when found. Don’t recast the whole language as “control flow theory”.
- Control Statements in Python — output: Pass then 0 then 1. if chooses, for repeats.
Technical Interview Tip: Decision + loop + jump overview.
Code Examples for Control Statements in Python
Example
# Control statements
marks = 72
if marks >= 40:
print("Pass")
for i in range(2):
print(i)
Control Statements in Python — output: Pass then 0 then 1. if chooses, for repeats.
How to Explain Control Statements in Python to an Interviewer
Explain Control Statements as if you are teaching a junior — definition, then one tiny script.
Decision: if Loop: for/while
What does the example print, and why?
Control Statements in Python — output: Pass then 0 then 1
What mistake do freshers make with Control Statements?
Jump: break/continue/pass