Interview Question

What are loops in Python?

for iterates over an iterable; while repeats while a condition is true.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

Python uses for and while statements for repeated execution. • `for` iterates over items from an iterable. • `while` repeats while its condition is true. • break, continue, and optional else clauses modify loop flow.

💡 Simple Example

for number in range(3): print(number)

Output

0 1 2

⚡ Quick Revision

for iterates over an iterable; while repeats while a condition is true.