Python 3 Tutorial chapters
  1. 01Python Basics & Environment Setup
  2. 02Operators & Expressions
  3. 03Control Flow & Loops
  4. 04Functions & Scope
  5. 05Data Structures: Lists & Tuples
  6. 06Dictionaries & Sets
  7. 07Strings & Text Processing
  8. 08Object-Oriented Programming (OOP)
  9. 09File Handling & I/O
  10. 10Exception Handling
  11. 11Advanced Python: Iterators & Decorators
  12. 12Modules & Virtual Environments

Chapter 3

Control Flow & Loops

5 topics in 3 parts

Full lessonPython Programming · Control Flow

Key ideas

Input Size (n) → Time (T) ↑ O(1) O(log n) O(n) O(n log n) O(n²) O(2ⁿ)
Control Flow & Loops
Pattern / FeatureIdiomatic Pythonic ApproachSub-optimal Anti-pattern
Data ProcessingComprehensions & Generators (Memory efficient)Manual loops with repeated append calls
Resource HandlingContext Managers (with statement)Manual open() and close() calls
Type AnnotationsType hinting via typing moduleUnannotated dynamic parameters
Dictionary Lookupsdict.get(key, default) or defaultdictKey check followed by indexed access

All 5 topics in Control Flow & Loops

  1. Conditionals

    • if, elif, else Conditional Statements
    • Nested Conditionals & Ternary Operator
  2. Loops

    • for Loops & range() Step Mechanics
    • while Loop & while...else
  3. Control

    • break, continue & pass Statements