Skip to content

← Back to Python Course Foundations

Basics of Python

Learning Objectives

  • Understand interpreter-based execution.
  • Write correctly indented Python programs.
  • Trace top-to-bottom flow with conditions.

Concept

Python executes statements sequentially and uses indentation to define code blocks.

Example

print("Start")
num = 5
if num > 0:
    print("Positive")
print("End")

Dry Run

  • Prints Start
  • num > 0 is true -> prints Positive
  • Prints End

Common Mistakes

  • Mixed tabs/spaces.
  • Missing indentation after if, for, while, def.

Practice

  1. Write a script that prints even/odd for one input.
  2. Add nested condition with proper indentation.