Topic 1 of 64
Python
Overview
Python is a high-level, interpreted language famous for its clean, readable syntax. It is the dominant language for data science, machine learning, automation, and backend development — making it the most versatile language to learn.
Syntax
python
# Python script
print("Hello, World!")
# Variables (dynamically typed)
name = "Priya"
age = 22
price = 9.99
is_active = True
# f-strings (modern string formatting)
greeting = f"Hello, {name}! You are {age} years old."
print(greeting)Common Pitfalls
- Python uses indentation for code blocks — mixing tabs and spaces causes IndentationError.
- Python is dynamically typed — variables can change type, which can cause bugs in large projects. Use type hints.
- Interview tip: Python uses pass-by-object-reference — immutables (int, str) behave like pass-by-value; mutables (list, dict) behave like pass-by-reference.
Real-World Example
A script to send daily sales report:
example
python
import datetime
sales_today = 1_45_320 # Indian number formatting
target = 2_00_000
date = datetime.date.today().strftime("%d %B %Y")
efficiency = (sales_today / target) * 100
report = f"""
📊 Daily Sales Report — {date}
─────────────────────────────
Sales Today : ₹{sales_today:,}
Target : ₹{target:,}
Efficiency : {efficiency:.1f}%
Status : {'✅ On Track' if efficiency >= 80 else '⚠️ Below Target'}
"""
print(report)