Introduction

Python is an expressive, general-purpose language famous for readability. These notes are concise and example-first.

# python 3.x
msg = "Hello, PEHTECH!"
print(msg)

Syntax

Whitespace is significant — use 4 spaces per indentation level.

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

Variables

Names use snake_case. Types are dynamic and inferred at runtime.

name = "Mujeeb"
age = 30
pi = 3.14159

Control Flow

x = 42
if x > 10:
    print("big")
else:
    print("small")

Functions

def greet(name: str) -> str:
    return f"Hello, {name}"

print(greet("Pehtech"))

Modules

import math
print(math.sqrt(16))