Complete Python Course
By Shri Chand Thapa Β· Published July 24, 2026
Comprehensive Python tutorial from basics to advanced topics, taught entirely with runnable code examples covering variables, strings, control flow, data structures, functions, and more.
- python
- tutorial
- beginner-to-advanced
- programming-fundamentals
Inside this notebook
# π Complete Python Course β Basics se Advanced tak (Hinglish) Namaste Shri! Yeh notebook ek **complete Python course** hai jisme hum zero se shuru karke advanced topics tak jayenge. Har concept ko **Hinglish** mein samjhaya gaya hai aur saath mein **runnable code** hai jise aap khud chala kar output dekh sakte ho. ## π Course ka Structure (15 Parts) | Part | Topic | Kya seekhoge | |------|-------|--------------| | 1 | **Basics** | Variables, data types, operators, I/O, f-strings | | 2 | **Strings** | String methods, slicing, formatting (deep) | | 3 | **Control Flow** | if/else, loops, break/continue/pass, match-case | | 4 | **Data Structures** | list, tuple, set, dict + `collections` module | | 5 | **Functions** | args/kwargs, scope (LEGB), lambda, closures | | 6 | **Functional Programming** | comprehensions, map/filter/reduce, itertools/functools | | 7 | **OOP** | classes, inheritance, polymorphism, dunder, dataclasses | | 8 | **Advanced OOP** | decorators, descriptors, metaclasses | | 9 | **Modules & Packages** | import, `__main__`, pip, venv | | 10 | **File Handling** | read/write, csv/json, pathlib | | 11 | **Exceptions** | try/except/finally, custom exceptions | | 12 | **Iterators & Generators** | iterator protocol, yield | | 13 | **Advanced** | context managers, type hints, regex, datetime | | 14 | **Concurrency** | threading, multiprocessing, asyncio, GIL | | 15 | **Memory & Best Practices** | garbage collection, references, tips | > π‘ **Tip:** Har code cell koβ¦
--- # π Part 1: Python Basics ## Python kya hai aur kyun? Python ek **high-level, interpreted, dynamically-typed** language hai. Iska matlab: - **High-level:** Insaan ke padhne jaisi syntax β `print("Hello")` likhna kaafi hai. - **Interpreted:** Code line-by-line chalta hai, compile karne ki zaroorat nahi. - **Dynamically-typed:** Variable ka type aapko likhna nahi padta β Python khud samajh jaata hai. ## 1.1 Variables aur Data Types Variable ek **container** hai jo data store karta hai. Python mein variable banane ke liye bas naam likho aur `=` se value do. Koi type declare karne ki zaroorat nahi!
# --- 1.1 Variables aur Data Types ---
# Variable banana: naam = value
naam = "Shri" # str (string - text)
age = 25 # int (integer - poora number)
height = 5.9 # float (decimal number)
is_student = True # bool (True / False)
skills = ["Python", "ML"] # list (collection)
# type() se pata karo ki variable ka type kya hai
print("naam ->", naam, " type:", type(naam).__name__)
print("age ->", age, " type:", type(age).__name__)
print("height ->", height, " type:", type(height).__name__)
print("is_student->", is_student, " type:", type(is_student).__name__)
print("skills ->", skills, "type:", type(skills).__name__)
print("\n--- Python ke 4 basic (primitive) types ---")
print("int : poore numbers -> 10, -5, 0")
β¦naam -> Shri type: str age -> 25 type: int height -> 5.9 type: float is_student-> True type: bool skills -> ['Python', 'ML'] type: list --- Python ke 4 basic (primitive) types --- int : poore numbers -> 10, -5, 0 float : decimal numbers -> 3.14, -0.5 str : text (quotes mein) -> 'hello' bool : True ya False
# --- 1.2 Operators ---
# Operators values par operations karte hain.
# Arithmetic operators (ganit)
print("=== Arithmetic ===")
print("10 + 3 =", 10 + 3) # addition
print("10 - 3 =", 10 - 3) # subtraction
print("10 * 3 =", 10 * 3) # multiplication
print("10 / 3 =", 10 / 3) # division (hamesha float deta hai)
print("10 // 3 =", 10 // 3) # floor division (poora bhaag)
print("10 % 3 =", 10 % 3) # modulus (remainder/bacha hua)
print("10 ** 3 =", 10 ** 3) # power (10 ki power 3)
# Comparison operators (tulna) -> hamesha bool dete hain
print("\n=== Comparison ===")
print("5 == 5 :", 5 == 5) # equal
print("5 != 3 :", 5 != 3) # not equal
print("5 > 3 :", 5 > 3) # greater than
β¦=== Arithmetic === 10 + 3 = 13 10 - 3 = 7 10 * 3 = 30 10 / 3 = 3.3333333333333335 10 // 3 = 3 10 % 3 = 1 10 ** 3 = 1000 === Comparison === 5 == 5 : True 5 != 3 : True 5 > 3 : True 5 <= 3 : False === Logical === True and False : False True or False : True not True : False x += 5 ke baad x = 15
# --- 1.3 Type Conversion (Casting) ---
# Ek type ko doosre type mein badalna.
num_str = "100" # yeh string hai, number nahi
num_int = int(num_str) # string -> int
print("int('100') ->", num_int, type(num_int).__name__)
print("float('3.14') ->", float("3.14"), type(float("3.14")).__name__)
print("str(25) ->", str(25), type(str(25)).__name__)
print("int(3.9) ->", int(3.9), "(decimal kaat diya, round nahi kiya)")
print("round(3.9) ->", round(3.9), "(round karta hai)")
print("bool(0) ->", bool(0), "| bool(5) ->", bool(5), "(0=False, baaki=True)")
print("bool('') ->", bool(""), "| bool('hi') ->", bool("hi"))
# list/tuple/set conversion
print("\nlist('abc') ->", list("abc"))
print("tuple([1,2]) ->", tuple([1, 2]))
print("set([1,1,2]) ->", set([1, 1, 2]), "(duplicates hat gaye)")int('100') -> 100 int
float('3.14') -> 3.14 float
str(25) -> 25 str
int(3.9) -> 3 (decimal kaat diya, round nahi kiya)
round(3.9) -> 4 (round karta hai)
bool(0) -> False | bool(5) -> True (0=False, baaki=True)
bool('') -> False | bool('hi') -> True
list('abc') -> ['a', 'b', 'c']
tuple([1,2]) -> (1, 2)
set([1,1,2]) -> {1, 2} (duplicates hat gaye)# --- 1.4 Input / Output aur f-strings ---
# print() se output
print("Hello, Python!")
print("Naam:", "Shri", "| Age:", 25) # comma se auto space
print("A", "B", "C", sep="-") # sep = separator
print("Line 1", end=" ") # end = line break nahi
print("Line 2")
# input() se user se data lete hain (notebook mein hum demo value use karenge)
# asli code mein: naam = input("Apna naam batao: ")
naam = "Shri" # demo
age = 25
# f-string (formatted string) - sabse modern aur clean tarika
print(f"\nMera naam {naam} hai aur main {age} saal ka hoon.")
print(f"Agla saal main {age + 1} saal ka hounga.")
print(f"10/3 = {10/3:.2f}") # .2f = 2 decimal places
β¦Hello, Python! Naam: Shri | Age: 25 A-B-C Line 1 Line 2 Mera naam Shri hai aur main 25 saal ka hoon. Agla saal main 26 saal ka hounga. 10/3 = 3.33 Naam: Shri Age: 25 Naam: Shri Age: 25
--- # π Part 2: Strings in Depth String **text** hota hai jo quotes (`' '` ya `" "`) mein likha jaata hai. Strings Python mein bahut important hain kyunki real-world data (naam, messages, files) zyada tar text hi hota hai. **Key baatein:** - Strings **immutable** hoti hain β ek baar ban gayi to badal nahi sakti. Naye changes ke liye nayi string banti hai. - Har character ka ek **index** hota hai: `0` se shuru (aage se), aur `-1` se (peeche se). - **Slicing** `[start:stop:step]` se string ka hissa nikaal sakte ho.
# --- 2.1 Indexing aur Slicing ---
s = "PYTHON"
# Index: P Y T H O N
# Aage: 0 1 2 3 4 5
# Peeche:-6 -5 -4 -3 -2 -1
print("s[0] =", s[0]) # pehla character
print("s[-1] =", s[-1]) # aakhri character
print("s[2] =", s[2])
# Slicing: s[start:stop:step] -> stop included NAHI hota
print("\n--- Slicing ---")
print("s[0:3] =", s[0:3]) # index 0,1,2 -> PYT
print("s[2:] =", s[2:]) # index 2 se end tak -> THON
print("s[:3] =", s[:3]) # start se index 2 tak -> PYT
print("s[:] =", s[:]) # poori copy
print("s[::-1]=", s[::-1]) # reverse string!
β¦This is a preview. Open the live notebook to see all 78 cells with their charts and full outputs, or fork it into your own Clusy workspace.