← Back to Index

Python Programming

From Zero to Advanced with Real-World Examples

START HERE

Python Learning Roadmap

This page takes you from your first Python statement to advanced programming concepts using practical real-world examples.

Beginner

Variables, data types, input, operators, conditions and loops.

Intermediate

Functions, lists, dictionaries, files, exceptions and modules.

Advanced

OOP, decorators, generators, APIs, databases and automation.

Real Projects

Billing systems, employee management, automation and data processing.

LEVEL 1 — BEGINNER

1. Your First Python Program

The first step is learning how to display information. Python uses the print() function.

Real-World Example 1: Display a Welcome Message
print("Welcome to our company!")
print("Python training has started.")
Welcome to our company!
Python training has started.

2. Variables and Data Types

Variables store information such as names, prices, quantities and customer details.

Real-World Example 2: Product Information
product_name = "Laptop"
price = 65000
quantity = 2
in_stock = True

print("Product:", product_name)
print("Price:", price)
print("Quantity:", quantity)
print("Available:", in_stock)
Product: Laptop
Price: 65000
Quantity: 2
Available: True

3. Taking User Input

The input() function allows a program to interact with users.

Real-World Example 3: Customer Registration
name = input("Enter customer name: ")
city = input("Enter city: ")

print("\nCustomer Details")
print("Name:", name)
print("City:", city)
User input is returned as text. Use int() or float() when numerical input is required.

4. Operators and Calculations

Python can perform mathematical calculations easily.

Real-World Example 4: Shopping Bill
price = 1200
quantity = 3

subtotal = price * quantity
gst = subtotal * 0.18
total = subtotal + gst

print("Subtotal:", subtotal)
print("GST:", gst)
print("Total Bill:", total)
Subtotal: 3600
GST: 648.0
Total Bill: 4248.0
LEVEL 2 — LOGIC

5. Conditions — if / elif / else

Conditions allow programs to make decisions.

Real-World Example 5: Employee Bonus
performance = 85

if performance >= 90:
    bonus = 20000
elif performance >= 75:
    bonus = 10000
else:
    bonus = 5000

print("Employee Bonus:", bonus)
Employee Bonus: 10000

6. Loops

Loops repeat a task multiple times. They are extremely useful for processing records.

Real-World Example 6: Process Customer Orders
orders = [1200, 850, 2300, 450, 1750]

for order in orders:
    print("Processing order:", order)
Instead of writing the same code for every order, a loop processes all orders automatically.

7. Functions

Functions allow you to organize reusable logic.

Real-World Example 7: Calculate Employee Salary
def calculate_salary(basic, allowance):
    return basic + allowance

salary = calculate_salary(40000, 10000)

print("Monthly Salary:", salary)
Monthly Salary: 50000

8. Lists

Lists store multiple values in a single variable.

Real-World Example 8: Product Inventory
products = [
    "Laptop",
    "Mouse",
    "Keyboard",
    "Monitor"
]

products.append("Printer")

for product in products:
    print(product)

9. Dictionaries

Dictionaries store information using key-value pairs. They are useful for representing real-world records.

Real-World Example 9: Employee Record
employee = {
    "id": 101,
    "name": "Rahul",
    "department": "IT",
    "salary": 55000
}

print("Employee:", employee["name"])
print("Department:", employee["department"])
print("Salary:", employee["salary"])
LEVEL 3 — INTERMEDIATE

10. File Handling

Python can create, read and update files. This is useful for reports, logs and data storage.

Real-World Example 10: Generate a Daily Sales Report
sales = [
    12000,
    18000,
    9500,
    22000
]

total_sales = sum(sales)

with open("sales_report.txt", "w") as file:
    file.write("Daily Sales Report\n")
    file.write("------------------\n")
    file.write(f"Total Sales: {total_sales}\n")

print("Sales report created.")
The with statement automatically handles closing the file after the operation is complete.

11. Exception Handling

Real applications need to handle unexpected situations without crashing.

Real-World Example 11: Safe Payment Calculation
try:
    amount = float(input("Enter payment amount: "))

    if amount <= 0:
        raise ValueError("Amount must be greater than zero")

    print("Payment accepted:", amount)

except ValueError as error:
    print("Invalid payment:", error)
LEVEL 4 — ADVANCED

12. Object-Oriented Programming

Classes and objects are useful for modelling real-world entities such as customers, employees, products and accounts.

Real-World Example 12: Bank Account
class BankAccount:

    def __init__(self, owner, balance):
        self.owner = owner
        self.balance = balance

    def deposit(self, amount):
        self.balance += amount

    def show_balance(self):
        print("Account Holder:", self.owner)
        print("Balance:", self.balance)


account = BankAccount("Amit", 25000)

account.deposit(5000)

account.show_balance()
Account Holder: Amit
Balance: 30000
LEVEL 5 — ADVANCED

Advanced Python Concepts

Once the fundamentals are comfortable, these concepts become important for larger applications.

List Comprehension

Create collections efficiently using concise expressions.

squares = [
    x * x for x in range(1, 6)
]

Lambda

Create small anonymous functions.

double = lambda x: x * 2

print(double(10))

Generator

Generate values one at a time instead of storing everything in memory.

def numbers():
    for i in range(5):
        yield i

Decorator

Add reusable behavior to functions.

def logger(func):

    def wrapper():
        print("Running function")
        return func()

    return wrapper

13. Working with APIs

APIs allow Python programs to communicate with other applications and services.

Real-World Example: Request Data from a Web API
import requests

url = "https://api.example.com/products"

response = requests.get(url)

if response.status_code == 200:
    data = response.json()

    for product in data:
        print(product)
else:
    print("Unable to retrieve data")
Replace the example URL with the documentation and endpoint of the API you are actually using.

14. Database Programming

Python can communicate with databases to store and retrieve application data.

Real-World Example: Employee Database
import sqlite3

connection = sqlite3.connect("company.db")

cursor = connection.cursor()

cursor.execute("""
CREATE TABLE IF NOT EXISTS employees (
    id INTEGER PRIMARY KEY,
    name TEXT,
    department TEXT
)
""")

cursor.execute("""
INSERT INTO employees
(name, department)
VALUES (?, ?)
""", ("Priya", "Finance"))

connection.commit()

print("Employee saved.")

connection.close()

15. Python Automation

Python can automate repetitive tasks such as creating folders, processing files and generating reports.

Real-World Example: Create Monthly Report Folders
from pathlib import Path

months = [
    "January",
    "February",
    "March",
    "April"
]

base_folder = Path("Reports")

for month in months:

    folder = base_folder / month

    folder.mkdir(
        parents=True,
        exist_ok=True
    )

    print("Created:", folder)
PRACTICE PROJECTS

Projects to Build After Learning Python

The fastest way to improve programming skills is to build complete projects.

Project Skills Practiced Level
Calculator Variables, input, operators Beginner
Student Result System Conditions, lists, functions Beginner
Billing System Lists, dictionaries, functions Intermediate
Employee Management OOP, files, databases Intermediate
Expense Tracker Files, dictionaries, functions Intermediate
Weather Application APIs, JSON, error handling Advanced
Automation Tool Pathlib, files, functions Advanced
Database Application SQL, SQLite, OOP Advanced

Recommended Learning Order

  1. Install Python and learn how to run a program.
  2. Learn print(), variables and data types.
  3. Learn input() and type conversion.
  4. Learn arithmetic and comparison operators.
  5. Learn if, elif and else.
  6. Learn for and while loops.
  7. Learn strings, lists, tuples and sets.
  8. Learn dictionaries.
  9. Learn functions.
  10. Learn modules and packages.
  11. Learn file handling.
  12. Learn exception handling.
  13. Learn Object-Oriented Programming.
  14. Learn APIs and JSON.
  15. Learn databases and SQL.
  16. Learn automation.
  17. Build complete projects.
Important: Don't just read the examples. Type the programs, run them, change the values and experiment with different inputs.

What You Can Build with Python

Web Applications

Build web applications and backend services.

Data Analysis

Process, analyze and visualize business data.

AI & Machine Learning

Build applications involving machine learning and artificial intelligence.

Automation

Automate repetitive business and computer tasks.

APIs

Connect applications and external services.

Desktop Tools

Create utilities and productivity applications.