Topic01 / 64
Introduction to Python
What & Why
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
1# Python script
2print("Hello, World!")
3
4# Variables (dynamically typed)
5name = "Priya"
6age = 22
7price = 9.99
8is_active = True
9
10# f-strings (modern string formatting)
11greeting = f"Hello, {name}! You are {age} years old."
12print(greeting)Real-World Example
A script to send daily sales report:
example.ts
python
1import datetime
2
3sales_today = 1_45_320 # Indian number formatting
4target = 2_00_000
5date = datetime.date.today().strftime("%d %B %Y")
6
7efficiency = (sales_today / target) * 100
8
9report = f"""
10📊 Daily Sales Report — {date}
11─────────────────────────────
12Sales Today : ₹{sales_today:,}
13Target : ₹{target:,}
14Efficiency : {efficiency:.1f}%
15Status : {'✅ On Track' if efficiency >= 80 else '⚠️ Below Target'}
16"""
17print(report)Pitfalls & Interview Tips
- ⚠️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.