PR 3

๐Ÿ PYTHON โ€“ DAY 1
Topic: Python Introduction & print() Function

๐Ÿ”น WHAT IS PYTHON?
Python ek high-level programming language hai jo simple English jaisi hoti hai.
WHY PYTHON?
Easy to learn
Beginner friendly
Web, AI, Automation, Data Science sab me use hoti hai
HOW PYTHON WORKS?
Python line by line execute hoti hai (Interpreter based).

๐Ÿ“˜ DAY 1 โ€“ 10 EXAMPLES

โœ… Example 1: Hello World

print("Hello World")

Explanation:

  • print() โ†’ output dikhata hai
  • "Hello World" โ†’ string (text)

โœ… Example 2: Apna Naam Print Karo

print("My name is Faheem")

๐Ÿ“Œ String hamesha quotes (” “) me hoti hai

โœ… Example 4: Multiple Print Statements

print("Python")
print("Programming")
print("Language")

๐Ÿ“Œ Har print() new line me output deta hai

โœ… Example 5: Print Using Comma

print("My age is", 20)

WHY comma?

  • Different data types ko ek sath print karne ke liye

โœ… Example 6: New Line (\n) Use

print("Hello\nWorld")

๐Ÿ“Œ \n โ†’ new line ke liye hota hai

โœ… Example 7: Single Quotes Use

print('Python is easy')

๐Ÿ“Œ Python me ' ' aur " " dono valid hain

โœ… Example 8: Double Quotes Inside String
print("Python is called \"Easy Language\"")

๐Ÿ“Œ \ escape character hota hai

โœ… Example 9: Print with sep
print("Python", "Java", "C++", sep=" | ")

output : Python | Java | C++

๐Ÿ“Œ sep separator change karta hai

โœ… Example 10: Print with end

print("Hello", end=" ")
print("World")

output : Hello World

๐Ÿ“Œ end new line ko replace karta hai

๐Ÿ“ DAY 1 SUMMARY (Notes Style)
  • print() โ†’ output ke liye
  • String โ†’ " " ya ' '
  • \n โ†’ new line
  • sep โ†’ separator
  • end โ†’ line ending control
๐Ÿ“Œ PRACTICE (Homework)
  1. Apna naam aur city print karo
  2. 3 favourite subjects print karo
  3. Ek line me naam aur age print karo

๐Ÿ PYTHON โ€“ DAY 2

Topic: Variables in Python

๐Ÿ”น VARIABLE KYA HAI? (WHAT)

Variable ek container hota hai jisme hum data store karte hain.

๐Ÿ”น VARIABLE KYON USE KARTE HAIN? (WHY)
  • Data ko bar-bar use karne ke liye
  • Code readable banane ke liye
  • Values change (update) karne ke liye
๐Ÿ”น VARIABLE KAISE BANATE HAIN? (HOW)

Python me = assignment operator se variable banta hai.

variable_name = value

๐Ÿ“˜ DAY 2 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Integer Variable
age = 20
print(age)

Explanation:

  • age โ†’ variable name
  • 20 โ†’ integer value
  • print(age) โ†’ value show karta hai
โœ… Example 2: Float Variable
price = 99.50
print(price)

๐Ÿ“Œ Decimal number = float


โœ… Example 3: String Variable
name = "Amit"
print(name)

๐Ÿ“Œ Text data hamesha quotes me hota hai


โœ… Example 4: Boolean Variable
is_student = True
print(is_student)

๐Ÿ“Œ Boolean sirf True / False hota hai


โœ… Example 5: Multiple Variables
name = "Rahul"
age = 21
city = "Delhi"

print(name)
print(age)
print(city)

๐Ÿ“Œ Alag-alag data ko alag variables me store kar sakte hain


โœ… Example 6: Print with Variables
name = "Neha"
age = 22

print("Name:", name)
print("Age:", age)

๐Ÿ“Œ String + variable print karne ke liye comma use hota hai


โœ… Example 7: Variable Overwrite
x = 10
print(x)

x = 20
print(x)

Explanation:

  • Pehle x = 10
  • Phir x = 20 โ†’ old value replace ho gayi

โœ… Example 8: Variable Swapping
a = 5
b = 10

a, b = b, a

print(a)
print(b)

๐Ÿ“Œ Python me swapping extra variable ke bina ho jati hai


โœ… Example 9: Type Check (type())
x = 100
y = 5.5
z = "Python"

print(type(x))
print(type(y))
print(type(z))

๐Ÿ“Œ type() batata hai variable ka data type


โœ… Example 10: Simple Calculation Using Variables
a = 10
b = 3

sum = a + b
print("Sum is:", sum)

๐Ÿ“Œ Variables ka use calculation ke liye hota hai


๐Ÿ“ DAY 2 SUMMARY (Notes)
  • Variable = data store karne ka box
  • Python me data type manually likhna nahi padta
  • = assignment operator hota hai
  • Value overwrite ho sakti hai
  • type() se data type check hota hai

๐Ÿง  DAY 2 PRACTICE (Homework)
  1. Apna naam, age aur college variable me store karo
  2. Do numbers ka multiplication variable se karo
  3. Ek boolean variable banao (True/False)

๐Ÿ PYTHON โ€“ DAY 3

Topic: Data Types & Type Conversion

๐Ÿ”น DATA TYPE KYA HAI? (WHAT)

Data type batata hai ki variable ke andar kis type ka data stored hai.

๐Ÿ”น DATA TYPE KYON ZAROORI HAI? (WHY)
  • Python ko samajhne ke liye ki kaunsa operation possible hai
  • Errors se bachne ke liye
  • Memory aur calculation sahi rakhne ke liye
๐Ÿ”น PYTHON KE MAIN DATA TYPES (HOW)
  • int โ†’ integer (whole number)
  • float โ†’ decimal number
  • str โ†’ string (text)
  • bool โ†’ True / False

๐Ÿ“˜ DAY 3 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Integer (int)
x = 50
print(x)
print(type(x))

๐Ÿ“Œ int โ†’ whole number (no decimal)


โœ… Example 2: Float (float)
price = 99.99
print(price)
print(type(price))

๐Ÿ“Œ Decimal value = float


โœ… Example 3: String (str)
language = "Python"
print(language)
print(type(language))

๐Ÿ“Œ Text data hamesha quotes me hota hai


โœ… Example 4: Boolean (bool)
is_active = True
print(is_active)
print(type(is_active))

๐Ÿ“Œ Boolean sirf True / False


โœ… Example 5: String + String
first_name = "Amit"
last_name = "Sharma"

print(first_name + last_name)

๐Ÿ“Œ Strings add hone par join (concatenate) ho jati hain


โœ… Example 6: Integer + Integer
a = 10
b = 20

print(a + b)

๐Ÿ“Œ Numbers add hone par math addition hota hai


โœ… Example 7: Integer + Float
x = 10
y = 2.5

print(x + y)

๐Ÿ“Œ Result hamesha float hota hai


โœ… Example 8: Type Conversion (int โ†’ float)
a = 5
b = float(a)

print(b)
print(type(b))

๐Ÿ“Œ float() โ†’ int ko float me convert karta hai


โœ… Example 9: Type Conversion (string โ†’ int)
num = "100"
num2 = int(num)

print(num2)
print(type(num2))

๐Ÿ“Œ String ke andar number hona chahiye, warna error aayega


โœ… Example 10: Wrong Type Example
a = "10"
b = 5

print(a + str(b))

Explanation:

  • a string hai
  • b int hai
  • Pehle b ko str() me convert kiya

๐Ÿ“Œ Same data type hona zaroori hai


๐Ÿ“ DAY 3 SUMMARY (Notes)
  • Data type batata hai data ka nature
  • Python automatically data type assign karta hai
  • type() se data type check hota hai
  • Type conversion โ†’ int(), float(), str()
  • Mixed data type me conversion zaroori hota hai

๐Ÿง  DAY 3 PRACTICE (Homework)
  1. Ek int ko float me convert karo
  2. User se number input leke uska square nikalo
  3. String aur number ko sahi tarike se add karo

๐Ÿ PYTHON โ€“ DAY 4

Topic: User Input (input() Function)

๐Ÿ”น INPUT KYA HAI? (WHAT)

Input ka matlab hota hai user se data lena.

๐Ÿ”น INPUT KYON ZAROORI HAI? (WHY)

  • Program ko dynamic banane ke liye
  • Har baar alag value ke saath program chalane ke liye

๐Ÿ”น INPUT KAISE LETE HAIN? (HOW)

Python me input() function ka use hota hai.

variable = input("Message")

๐Ÿ“Œ Important Note:
input() hamesha string data return karta hai.


๐Ÿ“˜ DAY 4 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Name Input
name = input("Enter your name: ")
print("Hello", name)

๐Ÿ“Œ User jo likhega, wo name variable me store ho jayega


โœ… Example 2: Age Input (String)
age = input("Enter your age: ")
print("Your age is", age)

๐Ÿ“Œ Yahan age string hai


โœ… Example 3: Age Input (Integer)
age = int(input("Enter your age: "))
print(age)

๐Ÿ“Œ int() use karke string โ†’ integer banaya


โœ… Example 4: Two Numbers Input
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

print("Sum is:", a + b)

๐Ÿ“Œ Calculation ke liye type conversion zaroori hai


โœ… Example 5: Float Input
price = float(input("Enter product price: "))
print("Price:", price)

๐Ÿ“Œ Decimal value ke liye float()


โœ… Example 6: Full Sentence Input
msg = input("Enter a message: ")
print(msg)

๐Ÿ“Œ Space ke saath bhi input accept hota hai


โœ… Example 7: Multiple Inputs (One Line)
name, city = input("Enter name and city: ").split()

print(name)
print(city)

๐Ÿ“Œ split() space ke base par data todta hai


โœ… Example 8: Calculate Square
num = int(input("Enter number: "))
print("Square:", num * num)

๐Ÿ“Œ User input se calculation


โœ… Example 9: String + Number (Correct Way)
age = int(input("Enter age: "))
print("Next year age:", age + 1)

๐Ÿ“Œ Pehle int conversion, phir addition


โœ… Example 10: Input Error Example
num = input("Enter number: ")
print(num + "10")

Explanation:

  • num string hai
  • "10" bhi string hai
  • Isliye result string join hoga

๐Ÿ“Œ Math ke liye conversion zaroori hai


๐Ÿ“ DAY 4 SUMMARY (Notes)
  • input() user se data leta hai
  • Input hamesha string hota hai
  • Math ke liye int() / float() use karo
  • split() multiple inputs ke liye useful
  • Galat conversion se error aa sakta hai

๐Ÿง  DAY 4 PRACTICE (Homework)
  1. User se 3 numbers input leke average nikalo
  2. User se naam aur age input leke print karo
  3. User se length input leke square nikalo

๐Ÿ PYTHON โ€“ DAY 5

Topic: Operators in Python


๐Ÿ”น OPERATOR KYA HAI? (WHAT)

Operator wo symbols hote hain jo kisi operation ko perform karte hain.

Example: + - * /


๐Ÿ”น OPERATOR KYON USE HOTE HAIN? (WHY)
  • Calculation karne ke liye
  • Comparison ke liye
  • Decision making ke liye

๐Ÿ”น PYTHON KE MAIN OPERATORS (HOW)

1๏ธโƒฃ Arithmetic Operators

2๏ธโƒฃ Comparison Operators

3๏ธโƒฃ Logical Operators


๐Ÿ“˜ DAY 5 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Addition (+)
a = 10
b = 5
print(a + b)

๐Ÿ“Œ + addition karta hai


โœ… Example 2: Subtraction (-)
a = 10
b = 5
print(a - b)

๐Ÿ“Œ - subtraction karta hai


โœ… Example 3: Multiplication (*)
a = 10
b = 5
print(a * b)

๐Ÿ“Œ * multiplication karta hai


โœ… Example 4: Division (/)
a = 10
b = 4
print(a / b)

๐Ÿ“Œ / ka result hamesha float hota hai


โœ… Example 5: Modulus (%)
a = 10
b = 3
print(a % b)

๐Ÿ“Œ % remainder deta hai


โœ… Example 6: Power (**)
a = 2
b = 3
print(a ** b)

๐Ÿ“Œ 2 ** 3 = 8


โœ… Example 7: Comparison Operator
a = 10
b = 5

print(a > b)
print(a < b)
print(a == b)

๐Ÿ“Œ Output True / False hota hai


โœ… Example 8: Logical AND (and)
age = 20
print(age > 18 and age < 25)

๐Ÿ“Œ Dono condition true honi chahiye


โœ… Example 9: Logical OR (or)
marks = 35
print(marks > 40 or marks == 35)

๐Ÿ“Œ Koi ek condition true ho to result true


โœ… Example 10: Operator Precedence
result = 10 + 2 * 5
print(result)

Explanation:

  • Pehle * hoga
  • Phir +

๐Ÿ“Œ Output: 20


๐Ÿ“ DAY 5 SUMMARY (Notes)
  • Arithmetic operators โ†’ calculation
  • Comparison operators โ†’ True / False
  • Logical operators โ†’ multiple conditions
  • / hamesha float deta hai
  • Operator precedence important hoti hai

๐Ÿง  DAY 5 PRACTICE (Homework)
  1. User se 2 numbers input leke sab arithmetic operations karo
  2. Check karo number even ya odd (%)
  3. Age check program using logical operators

๐Ÿ PYTHON โ€“ DAY 6

Topic: if Statement (Decision Making)


๐Ÿ”น IF STATEMENT KYA HAI? (WHAT)

if statement ka use condition check karne ke liye hota hai.

๐Ÿ”น IF KYON USE KARTE HAIN? (WHY)
  • Decision lene ke liye
  • Condition ke base par code chalane ke liye
๐Ÿ”น IF KAISE KAAM KARTA HAI? (HOW)
if condition:
    statement

๐Ÿ“Œ Agar condition True hogi tabhi code chalega


๐Ÿ“˜ DAY 6 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple if
age = 20

if age >= 18:
    print("You are adult")

๐Ÿ“Œ Condition true hai isliye print hua


โœ… Example 2: Positive Number Check
num = 5

if num > 0:
    print("Positive number")

โœ… Example 3: Number Greater Than 10
num = 15

if num > 10:
    print("Number is greater than 10")

โœ… Example 4: Even Number Check
num = 8

if num % 2 == 0:
    print("Even number")

๐Ÿ“Œ % remainder check karta hai


โœ… Example 5: Password Check
password = "admin123"

if password == "admin123":
    print("Login successful")

โœ… Example 6: Boolean Condition
is_logged_in = True

if is_logged_in:
    print("Welcome user")

๐Ÿ“Œ Boolean directly condition me use ho sakta hai


โœ… Example 7: User Input with if
age = int(input("Enter age: "))

if age >= 18:
    print("You can vote")

โœ… Example 8: Marks Check
marks = 75

if marks >= 40:
    print("Pass")

โœ… Example 9: Temperature Check
temp = 30

if temp > 25:
    print("Weather is hot")

โœ… Example 10: Real Life Example (Discount)
amount = 6000

if amount > 5000:
    print("You got 10% discount")

๐Ÿ“ DAY 6 SUMMARY (Notes)

  • if condition check karta hai
  • Condition true hone par hi code chalega
  • Comparison & logical operators use hote hain
  • Indentation (space) bahut important hai

๐Ÿง  DAY 6 PRACTICE (Homework)

  1. User se number input leke positive check karo
  2. User se marks input leke pass check karo
  3. User se age input leke driving eligibility check karo

๐Ÿ PYTHON โ€“ DAY 7

Topic: if - else Statement


๐Ÿ”น IFโ€“ELSE KYA HAI? (WHAT)

if-else ka use tab hota hai jab do conditions ho:

  • agar condition True
  • ya phir False

๐Ÿ”น IFโ€“ELSE KYON USE KARTE HAIN? (WHY)
  • Decision making ke liye
  • Dono situations handle karne ke liye

๐Ÿ”น IFโ€“ELSE KAISE LIKHTE HAIN? (HOW)
if condition:
    statement
else:
    statement

๐Ÿ“Œ Agar if false ho jaye, to else chalega


๐Ÿ“˜ DAY 7 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Even or Odd
num = 7

if num % 2 == 0:
    print("Even number")
else:
    print("Odd number")

โœ… Example 2: Adult or Minor
age = 16

if age >= 18:
    print("Adult")
else:
    print("Minor")

โœ… Example 3: Pass or Fail
marks = 35

if marks >= 40:
    print("Pass")
else:
    print("Fail")

โœ… Example 4: Greater Number
a = 10
b = 20

if a > b:
    print("a is greater")
else:
    print("b is greater")

โœ… Example 5: Voting Eligibility (User Input)
age = int(input("Enter age: "))

if age >= 18:
    print("You can vote")
else:
    print("You cannot vote")

โœ… Example 6: Login Validation
username = "admin"

if username == "admin":
    print("Login successful")
else:
    print("Invalid user")

โœ… Example 7: Temperature Check
temp = 20

if temp > 25:
    print("Hot weather")
else:
    print("Normal weather")

โœ… Example 8: Discount Condition
amount = 3000

if amount >= 5000:
    print("Discount applied")
else:
    print("No discount")

โœ… Example 9: Positive or Negative
num = -5

if num >= 0:
    print("Positive number")
else:
    print("Negative number")

โœ… Example 10: Password Check
password = input("Enter password: ")

if password == "python123":
    print("Access granted")
else:
    print("Wrong password")

๐Ÿ“ DAY 7 SUMMARY (Notes)

  • if-else two condition handle karta hai
  • Ek hi block execute hota hai
  • Logical & comparison operators ka use hota hai
  • Indentation bahut important hai

๐Ÿง  DAY 7 PRACTICE (Homework)

  1. User se number input leke even/odd check karo
  2. User se marks input leke pass/fail check karo
  3. User se password input leke match karo

๐Ÿ PYTHON โ€“ DAY 8

Topic: if - elif - else Statement (Multiple Conditions)


๐Ÿ”น IFโ€“ELIFโ€“ELSE KYA HAI? (WHAT)

Jab multiple conditions check karni hoti hain, tab if-elif-else use hota hai.


๐Ÿ”น IFโ€“ELIFโ€“ELSE KYON USE KARTE HAIN? (WHY)

  • Ek se zyada decision lene ke liye
  • Multiple cases handle karne ke liye

๐Ÿ”น IFโ€“ELIFโ€“ELSE KAISE LIKHTE HAIN? (HOW)

if condition1:
    statement
elif condition2:
    statement
else:
    statement

๐Ÿ“Œ Pehli true condition ka code chalega


๐Ÿ“˜ DAY 8 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Grade System

marks = 85

if marks >= 90:
    print("Grade A")
elif marks >= 75:
    print("Grade B")
else:
    print("Grade C")

โœ… Example 2: Number Range Check

num = 5

if num < 0:
    print("Negative")
elif num == 0:
    print("Zero")
else:
    print("Positive")

โœ… Example 3: Day Name Program

day = 3

if day == 1:
    print("Monday")
elif day == 2:
    print("Tuesday")
elif day == 3:
    print("Wednesday")
else:
    print("Invalid day")

โœ… Example 4: Simple Calculator

a = 10
b = 5
choice = "+"

if choice == "+":
    print(a + b)
elif choice == "-":
    print(a - b)
else:
    print("Invalid choice")

โœ… Example 5: Age Category

age = 65

if age < 18:
    print("Child")
elif age < 60:
    print("Adult")
else:
    print("Senior Citizen")

โœ… Example 6: Temperature Level

temp = 15

if temp > 30:
    print("Hot")
elif temp > 20:
    print("Warm")
else:
    print("Cold")

โœ… Example 7: Login Role

role = "admin"

if role == "admin":
    print("Full access")
elif role == "user":
    print("Limited access")
else:
    print("Guest access")

โœ… Example 8: Electricity Bill Logic

units = 120

if units <= 100:
    print("Low usage")
elif units <= 200:
    print("Medium usage")
else:
    print("High usage")

โœ… Example 9: Marks Result

marks = 30

if marks >= 40:
    print("Pass")
elif marks >= 30:
    print("Grace")
else:
    print("Fail")

โœ… Example 10: Menu Based Choice

choice = 2

if choice == 1:
    print("Pizza")
elif choice == 2:
    print("Burger")
elif choice == 3:
    print("Pasta")
else:
    print("Invalid choice")

๐Ÿ“ DAY 8 SUMMARY (Notes)

  • if-elif-else multiple conditions ke liye hota hai
  • Sirf ek block execute hota hai
  • Conditions top to bottom check hoti hain
  • Order bahut important hota hai

๐Ÿง  DAY 8 PRACTICE (Homework)

  1. User se marks input leke grade system banao
  2. User se number input leke positive/negative/zero check karo
  3. User se choice input leke menu program banao

๐Ÿ PYTHON โ€“ DAY 9

Topic: for Loop (Iteration / Repetition)

๐Ÿ”น FOR LOOP KYA HAI? (WHAT)

for loop ka use kisi kaam ko baar-baar repeat karne ke liye hota hai.


๐Ÿ”น FOR LOOP KYON USE KARTE HAIN? (WHY)

  • Repetitive tasks ke liye
  • Series (1 to 10) print karne ke liye
  • Collection (list, string) ke elements access karne ke liye

๐Ÿ”น FOR LOOP KAISE KAAM KARTA HAI? (HOW)

for variable in sequence:
    statement

๐Ÿ“Œ Python me mostly range() function use hota hai


๐Ÿ“˜ DAY 9 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: 1 to 5 Print
for i in range(1, 6):
    print(i)

๐Ÿ“Œ range(1,6) โ†’ 1 se 5 tak


โœ… Example 2: 1 to 10 Print
for i in range(1, 11):
    print(i)

โœ… Example 3: Even Numbers (1โ€“10)
for i in range(2, 11, 2):
    print(i)

๐Ÿ“Œ 2 โ†’ start, 11 โ†’ stop, 2 โ†’ step


โœ… Example 4: Odd Numbers (1โ€“10)
for i in range(1, 11, 2):
    print(i)

โœ… Example 5: Reverse Counting
for i in range(10, 0, -1):
    print(i)

๐Ÿ“Œ Negative step se reverse loop


โœ… Example 6: Table of 2
for i in range(1, 11):
    print("2 x", i, "=", 2 * i)

โœ… Example 7: Table of n (User Input)
n = int(input("Enter number: "))

for i in range(1, 11):
    print(n, "x", i, "=", n * i)

โœ… Example 8: Sum of 1 to 5
total = 0

for i in range(1, 6):
    total = total + i

print("Sum is:", total)

โœ… Example 9: Loop with String
name = "Python"

for ch in name:
    print(ch)

๐Ÿ“Œ String ke har character par loop chalta hai


โœ… Example 10: Condition Inside Loop
for i in range(1, 11):
    if i == 5:
        print("Five found")
    else:
        print(i)

๐Ÿ“ DAY 9 SUMMARY (Notes)
  • for loop repetition ke liye use hota hai
  • range(start, stop, step) common hai
  • Loop string & numbers dono par chalta hai
  • Condition loop ke andar bhi lag sakti hai

๐Ÿง  DAY 9 PRACTICE (Homework)
  1. 1 se 20 tak numbers print karo
  2. 1 se 10 tak even numbers ka sum nikalo
  3. Apna naam letter by letter print karo

๐Ÿ PYTHON โ€“ DAY 10

Topic: while Loop


๐Ÿ”น WHILE LOOP KYA HAI? (WHAT)

while loop tab tak repeat hota hai jab tak condition True rahe.


๐Ÿ”น WHILE LOOP KYON USE KARTE HAIN? (WHY)
  • Jab iterations ka count pehle se pata na ho
  • Condition based repetition ke liye

๐Ÿ”น WHILE LOOP KAISE KAAM KARTA HAI? (HOW)

while condition:
    statement

๐Ÿ“Œ Condition false hote hi loop stop ho jata hai


๐Ÿ“˜ DAY 10 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: 1 to 5 Print
i = 1
while i <= 5:
    print(i)
    i += 1

๐Ÿ“Œ i += 1 infinite loop se bachata hai


โœ… Example 2: 1 to 10 Print
i = 1
while i <= 10:
    print(i)
    i = i + 1

โœ… Example 3: Reverse Counting
i = 10
while i >= 1:
    print(i)
    i -= 1

โœ… Example 4: Table of 5
i = 1
while i <= 10:
    print("5 x", i, "=", 5 * i)
    i += 1

โœ… Example 5: Sum of Numbers
i = 1
total = 0

while i <= 5:
    total = total + i
    i += 1

print("Sum is:", total)

โœ… Example 6: Even Numbers (1โ€“10)
i = 2
while i <= 10:
    print(i)
    i += 2

โœ… Example 7: User Controlled Loop
num = int(input("Enter number: "))

while num > 0:
    print(num)
    num -= 1

๐Ÿ“Œ Loop user input pe depend karta hai


โœ… Example 8: Infinite Loop (STOP MANUALLY)
while True:
    print("Python")

๐Ÿ“Œ Ye infinite loop hai


โœ… Example 9: Break Statement
i = 1
while i <= 10:
    if i == 5:
        break
    print(i)
    i += 1

๐Ÿ“Œ break loop ko turant stop karta hai


โœ… Example 10: Continue Statement
i = 0
while i < 5:
    i += 1
    if i == 3:
        continue
    print(i)

๐Ÿ“Œ continue current iteration skip karta hai


๐Ÿ“ DAY 10 SUMMARY (Notes)
  • while loop condition based hota hai
  • Counter update zaroori hai
  • break loop tod deta hai
  • continue ek iteration skip karta hai
  • Galat condition se infinite loop ban sakta hai

๐Ÿง  DAY 10 PRACTICE (Homework)
  1. User se number input leke uska factorial nikalo
  2. While loop se table print karo
  3. Countdown program banao

๐Ÿ PYTHON โ€“ DAY 11

Topic: Nested Loops (Loop ke andar Loop)


๐Ÿ”น NESTED LOOP KYA HAI? (WHAT)

Jab ek loop ke andar doosra loop hota hai, use Nested Loop kehte hain.


๐Ÿ”น NESTED LOOP KYON USE KARTE HAIN? (WHY)

  • Pattern printing ke liye
  • Table ke andar table ke liye
  • Complex repetition problems ke liye

๐Ÿ”น NESTED LOOP KAISE KAAM KARTA HAI? (HOW)

for outer in range():
    for inner in range():
        statement

๐Ÿ“Œ Pehle outer loop chalta hai, uske andar inner loop complete hota hai


๐Ÿ“˜ DAY 11 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Nested Loop

for i in range(1, 4):
    for j in range(1, 4):
        print(i, j)

๐Ÿ“Œ Har i ke liye j poora chalega


โœ… Example 2: 2 Tables (1โ€“3)

for i in range(1, 4):
    for j in range(1, 11):
        print(i, "x", j, "=", i * j)
    print("------")

๐Ÿ“Œ Table ke baad line separation


โœ… Example 3: Square Pattern

for i in range(3):
    for j in range(3):
        print("*", end=" ")
    print()

๐Ÿ“Œ end=" " same line me print karta hai


โœ… Example 4: Number Pattern

for i in range(1, 4):
    for j in range(1, 4):
        print(j, end=" ")
    print()

โœ… Example 5: Increasing Star Pattern

for i in range(1, 6):
    for j in range(i):
        print("*", end=" ")
    print()

โœ… Example 6: Decreasing Star Pattern

for i in range(5, 0, -1):
    for j in range(i):
        print("*", end=" ")
    print()

โœ… Example 7: Number Triangle

for i in range(1, 5):
    for j in range(1, i + 1):
        print(j, end=" ")
    print()

โœ… Example 8: Same Number Pattern

for i in range(1, 5):
    for j in range(i):
        print(i, end=" ")
    print()

โœ… Example 9: Using While Inside For

for i in range(1, 4):
    j = 1
    while j <= 3:
        print(i, j)
        j += 1

โœ… Example 10: Real-Life Example (Class & Students)

for cls in range(1, 4):
    for student in range(1, 6):
        print("Class", cls, "Student", student)

๐Ÿ“ DAY 11 SUMMARY (Notes)
  • Nested loop = loop ke andar loop
  • Outer loop ek baar, inner loop multiple baar
  • Patterns banane me bahut use hota hai
  • end="" line control karta hai

๐Ÿง  DAY 11 PRACTICE (Homework)
  1. 4ร—4 star pattern banao
  2. User se number leke triangle pattern banao
  3. 1 se 5 tak sab tables print karo

๐Ÿ PYTHON โ€“ DAY 12

Topic: Pattern Printing (Using Loops)


๐Ÿ”น PATTERN PRINTING KYA HAI? (WHAT)

Pattern printing ka matlab hota hai stars (*), numbers ya characters ka design banana using loops.


๐Ÿ”น PATTERN PRINTING KYON ZAROORI HAI? (WHY)

  • Loop logic strong hota hai
  • Interview & exams me common hota hai
  • Nested loops ka best use samajh aata hai

๐Ÿ”น PATTERN KAISE BANTE HAIN? (HOW)

  • Outer loop โ†’ rows
  • Inner loop โ†’ columns
  • end="" โ†’ same line me print ke liye

๐Ÿ“˜ DAY 12 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Square Star Pattern

for i in range(4):
    for j in range(4):
        print("*", end=" ")
    print()

โœ… Example 2: Right Angle Triangle

for i in range(1, 6):
    for j in range(i):
        print("*", end=" ")
    print()

โœ… Example 3: Inverted Triangle

for i in range(5, 0, -1):
    for j in range(i):
        print("*", end=" ")
    print()

โœ… Example 4: Number Square

for i in range(1, 5):
    for j in range(1, 5):
        print(j, end=" ")
    print()

โœ… Example 5: Number Triangle

for i in range(1, 5):
    for j in range(1, i + 1):
        print(j, end=" ")
    print()

โœ… Example 6: Same Number Pattern

for i in range(1, 5):
    for j in range(i):
        print(i, end=" ")
    print()

โœ… Example 7: Alphabet Pattern

for i in range(65, 70):
    for j in range(65, i + 1):
        print(chr(j), end=" ")
    print()

๐Ÿ“Œ chr() ASCII value ko character me convert karta hai


โœ… Example 8: Pyramid Pattern

rows = 5
for i in range(rows):
    for space in range(rows - i - 1):
        print(" ", end="")
    for star in range(2 * i + 1):
        print("*", end="")
    print()

โœ… Example 9: Reverse Pyramid

rows = 5
for i in range(rows, 0, -1):
    for space in range(rows - i):
        print(" ", end="")
    for star in range(2 * i - 1):
        print("*", end="")
    print()

โœ… Example 10: Diamond Pattern

rows = 4

for i in range(rows):
    for space in range(rows - i - 1):
        print(" ", end="")
    for star in range(2 * i + 1):
        print("*", end="")
    print()

for i in range(rows - 1, 0, -1):
    for space in range(rows - i):
        print(" ", end="")
    for star in range(2 * i - 1):
        print("*", end="")
    print()

๐Ÿ“ DAY 12 SUMMARY (Notes)

  • Pattern = nested loop logic
  • Outer loop โ†’ rows
  • Inner loop โ†’ columns
  • end="" same line me print karta hai
  • Space control se pyramid banta hai

๐Ÿง  DAY 12 PRACTICE (Homework)

  1. User se rows input leke pyramid banao
  2. Number pyramid banao
  3. Alphabet square pattern banao

๐Ÿ PYTHON โ€“ DAY 13

Topic: Strings โ€“ Basics


๐Ÿ”น STRING KYA HOTI HAI? (WHAT)

String ek sequence of characters hoti hai jo text ko represent karti hai.

Example:
"Python", "Hello World"


๐Ÿ”น STRING KYON USE HOTI HAI? (WHY)
  • Naam, message, sentence store karne ke liye
  • User input handle karne ke liye
  • Text processing ke liye

๐Ÿ”น STRING KAISE BANTI HAI? (HOW)

String single (' ') ya double (" ") quotes me likhi jaati hai.


๐Ÿ“˜ DAY 13 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple String

name = "Python"
print(name)

๐Ÿ“Œ String quotes me hoti hai


โœ… Example 2: String with Spaces

msg = "Python is easy"
print(msg)

๐Ÿ“Œ Space bhi string ka part hota hai


โœ… Example 3: Single Quotes

course = 'Programming'
print(course)

โœ… Example 4: Multiline String

text = """Python
is
awesome"""
print(text)

๐Ÿ“Œ Triple quotes multi-line ke liye


โœ… Example 5: String Indexing

word = "Python"
print(word[0])
print(word[3])

๐Ÿ“Œ Index 0 se start hota hai


โœ… Example 6: Negative Indexing

word = "Python"
print(word[-1])
print(word[-2])

๐Ÿ“Œ Negative index peeche se count karta hai


โœ… Example 7: String Length

word = "Programming"
print(len(word))

๐Ÿ“Œ len() length batata hai


โœ… Example 8: String Concatenation

a = "Hello"
b = "World"
print(a + " " + b)

๐Ÿ“Œ + se strings join hoti hain


โœ… Example 9: String Repetition

word = "Hi "
print(word * 3)

๐Ÿ“Œ * string repeat karta hai


โœ… Example 10: Loop Through String

name = "Python"

for ch in name:
    print(ch)

๐Ÿ“Œ Har character print hoga


๐Ÿ“ DAY 13 SUMMARY (Notes)

  • String = text data
  • Indexing 0 se start hoti hai
  • Negative indexing supported
  • len() length batata hai
  • + join & * repeat karta hai

๐Ÿง  DAY 13 PRACTICE (Homework)

  1. Apna naam string me store karke letters print karo
  2. User se string input leke length print karo
  3. Do strings join karke print karo

๐Ÿ PYTHON โ€“ DAY 14

Topic: String Functions / Methods

๐Ÿ”น STRING METHOD KYA HAI? (WHAT)

String methods wo built-in functions hote hain jo string par kaam karte hain.

Example:
upper(), lower(), strip()


๐Ÿ”น STRING METHODS KYON USE KARTE HAIN? (WHY)
  • Text ko modify karne ke liye
  • Data cleaning ke liye
  • Search & formatting ke liye

๐Ÿ”น STRING METHODS KAISE USE HOTE HAIN? (HOW)
string.method()

๐Ÿ“˜ DAY 14 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: upper()

text = "python"
print(text.upper())

๐Ÿ“Œ Sab letters capital ho jaate hain


โœ… Example 2: lower()

text = "PYTHON"
print(text.lower())

๐Ÿ“Œ Sab letters small ho jaate hain


โœ… Example 3: title()

text = "python programming language"
print(text.title())

๐Ÿ“Œ Har word ka first letter capital


โœ… Example 4: capitalize()

text = "python is easy"
print(text.capitalize())

๐Ÿ“Œ Sirf first letter capital


โœ… Example 5: strip()

text = "  hello  "
print(text.strip())

๐Ÿ“Œ Extra spaces remove karta hai


โœ… Example 6: replace()

text = "I like Java"
print(text.replace("Java", "Python"))

๐Ÿ“Œ Word replace karta hai


โœ… Example 7: find()

text = "Python Programming"
print(text.find("Program"))

๐Ÿ“Œ Word ka index return karta hai


โœ… Example 8: count()

text = "banana"
print(text.count("a"))

๐Ÿ“Œ Character kitni baar aaya


โœ… Example 9: startswith() / endswith()

text = "python.py"
print(text.startswith("python"))
print(text.endswith(".py"))

๐Ÿ“Œ True / False return karta hai


โœ… Example 10: split()

text = "Python is easy"
words = text.split()
print(words)

๐Ÿ“Œ String ko list me tod deta hai


๐Ÿ“ DAY 14 SUMMARY (Notes)

  • String methods text ko modify karte hain
  • Original string change nahi hoti (immutable)
  • Methods dot (.) se call hote hain
  • Text processing me bahut important

๐Ÿง  DAY 14 PRACTICE (Homework)

  1. User se name input leke capital me print karo
  2. User se sentence leke word count karo
  3. Email id .com se end ho rahi hai ya nahi check karo

๐Ÿ PYTHON โ€“ DAY 15

Topic: String Programs / Logic

๐Ÿ”น STRING PROGRAMS KYA HAIN? (WHAT)

String programs me text manipulation aur logic use hota hai jaise palindrome check, reverse karna, count karna.


๐Ÿ”น KYON USE KARTE HAIN? (WHY)

  • Real-life text data process karne ke liye
  • Programming logic practice ke liye
  • Coding interview ke liye

๐Ÿ”น STRING PROGRAMS KAISE BANATE HAIN? (HOW)

  • Loops, conditions aur string methods ka combination use karte hain
  • Indexing aur slicing help karta hai

๐Ÿ“˜ DAY 15 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Reverse a String

text = "Python"
print(text[::-1])

๐Ÿ“Œ [::-1] string reverse karta hai


โœ… Example 2: Check Palindrome

word = "madam"
if word == word[::-1]:
    print("Palindrome")
else:
    print("Not Palindrome")

โœ… Example 3: Count Characters

text = "banana"
count = text.count("a")
print("a appears", count, "times")

โœ… Example 4: Count Vowels

text = "Python"
vowels = "aeiouAEIOU"
count = 0
for ch in text:
    if ch in vowels:
        count += 1
print("Vowels:", count)

โœ… Example 5: Uppercase & Lowercase Count

text = "Python Programming"
upper = 0
lower = 0
for ch in text:
    if ch.isupper():
        upper += 1
    elif ch.islower():
        lower += 1
print("Upper:", upper, "Lower:", lower)

โœ… Example 6: First and Last Character

text = "Python"
print("First:", text[0])
print("Last:", text[-1])

โœ… Example 7: Remove Spaces

text = " P y t h o n "
clean = text.replace(" ", "")
print(clean)

โœ… Example 8: Count Words

sentence = "Python is easy"
words = sentence.split()
print("Number of words:", len(words))

โœ… Example 9: String Palindrome Ignoring Case

text = "Madam"
if text.lower() == text[::-1].lower():
    print("Palindrome")
else:
    print("Not Palindrome")

โœ… Example 10: Check Substring

text = "I love Python"
if "Python" in text:
    print("Found")
else:
    print("Not Found")

๐Ÿ“ DAY 15 SUMMARY (Notes)

  • String slicing aur methods ka use hota hai
  • Loops aur conditions text manipulation ke liye
  • Palindrome, reverse, count sab possible hai
  • Case sensitivity aur spaces ka dhyan rakho

๐Ÿง  DAY 15 PRACTICE (Homework)

  1. User input leke palindrome check karo
  2. User input ka reverse print karo
  3. User sentence me vowels count karo

๐Ÿ PYTHON โ€“ DAY 16

Topic: Lists โ€“ Basics


๐Ÿ”น LIST KYA HOTI HAI? (WHAT)

List ek collection data type hai jisme hum multiple values ek hi variable me store kar sakte hain.

Example:
[10, 20, 30]
["apple", "banana", "mango"]


๐Ÿ”น LIST KYON USE KARTE HAIN? (WHY)

  • Multiple data store karne ke liye
  • Ordered data chahiye ho
  • Index ke through access karna ho

๐Ÿ”น LIST KAISE BANATE HAIN? (HOW)

List square brackets [ ] me banti hai.

list_name = [values]

๐Ÿ“˜ DAY 16 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple List

numbers = [10, 20, 30, 40]
print(numbers)

๐Ÿ“Œ List values comma se separated hoti hain


โœ… Example 2: Mixed Data List

data = [10, "Python", 3.5, True]
print(data)

๐Ÿ“Œ List me different data types ho sakte hain


โœ… Example 3: Access List Elements

fruits = ["apple", "banana", "mango"]
print(fruits[0])
print(fruits[2])

๐Ÿ“Œ Index 0 se start hota hai


โœ… Example 4: Negative Indexing

fruits = ["apple", "banana", "mango"]
print(fruits[-1])

๐Ÿ“Œ -1 last element deta hai


โœ… Example 5: List Length

items = ["pen", "book", "bag"]
print(len(items))

๐Ÿ“Œ len() list ke elements count karta hai


โœ… Example 6: Loop Through List

colors = ["red", "green", "blue"]

for c in colors:
    print(c)

๐Ÿ“Œ List ke har element par loop chalega


โœ… Example 7: Modify List Element

numbers = [1, 2, 3]
numbers[1] = 20
print(numbers)

๐Ÿ“Œ List mutable hoti hai (change ho sakti hai)


โœ… Example 8: Add Element (append)

numbers = [1, 2, 3]
numbers.append(4)
print(numbers)

๐Ÿ“Œ append() end me value add karta hai


โœ… Example 9: Insert Element

numbers = [1, 2, 3]
numbers.insert(1, 10)
print(numbers)

๐Ÿ“Œ insert(index, value)


โœ… Example 10: Remove Element

numbers = [1, 2, 3, 4]
numbers.remove(3)
print(numbers)

๐Ÿ“Œ First matching value remove hoti hai


๐Ÿ“ DAY 16 SUMMARY (Notes)

  • List = multiple values ka collection
  • Ordered & mutable hoti hai
  • Indexing support karti hai
  • append(), insert(), remove() common methods hain

๐Ÿง  DAY 16 PRACTICE (Homework)

  1. User se 5 numbers input leke list banao
  2. List ka first aur last element print karo
  3. List me ek new element add karo

๐Ÿ PYTHON โ€“ DAY 17

Topic: List Methods & Operations


๐Ÿ”น LIST METHODS KYA HAIN? (WHAT)

List methods wo built-in functions hote hain jo list par directly kaam karte hain.

Example:
append(), pop(), sort()


๐Ÿ”น LIST METHODS KYON USE KARTE HAIN? (WHY)

  • List ko modify karne ke liye
  • Data add / remove / arrange karne ke liye
  • Programming logic easy banane ke liye

๐Ÿ”น LIST METHODS KAISE USE HOTE HAIN? (HOW)

list_name.method()

๐Ÿ“˜ DAY 17 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: append()

numbers = [1, 2, 3]
numbers.append(4)
print(numbers)

๐Ÿ“Œ List ke end me value add hoti hai


โœ… Example 2: extend()

list1 = [1, 2]
list2 = [3, 4]
list1.extend(list2)
print(list1)

๐Ÿ“Œ Ek list ko doosri list me add karta hai


โœ… Example 3: insert()

numbers = [10, 20, 30]
numbers.insert(1, 15)
print(numbers)

๐Ÿ“Œ Specific index par value add hoti hai


โœ… Example 4: remove()

numbers = [1, 2, 3, 2]
numbers.remove(2)
print(numbers)

๐Ÿ“Œ First matching element remove hota hai


โœ… Example 5: pop()

numbers = [10, 20, 30]
numbers.pop()
print(numbers)

๐Ÿ“Œ Last element remove karta hai


โœ… Example 6: pop(index)

numbers = [10, 20, 30]
numbers.pop(1)
print(numbers)

๐Ÿ“Œ Index ke according element remove


โœ… Example 7: sort()

numbers = [5, 2, 8, 1]
numbers.sort()
print(numbers)

๐Ÿ“Œ Ascending order me arrange karta hai


โœ… Example 8: reverse()

numbers = [1, 2, 3]
numbers.reverse()
print(numbers)

๐Ÿ“Œ List ko reverse karta hai


โœ… Example 9: count()

numbers = [1, 2, 2, 3]
print(numbers.count(2))

๐Ÿ“Œ Element kitni baar hai


โœ… Example 10: index()

numbers = [10, 20, 30]
print(numbers.index(20))

๐Ÿ“Œ Element ka index batata hai


๐Ÿ“ DAY 17 SUMMARY (Notes)

  • List methods list ko modify karte hain
  • append, insert, extend โ†’ add
  • remove, pop โ†’ delete
  • sort, reverse โ†’ arrange
  • List mutable hoti hai

๐Ÿง  DAY 17 PRACTICE (Homework)

  1. User se numbers input leke list sort karo
  2. List me duplicate elements count karo
  3. List ka max aur min element find karo

๐Ÿ PYTHON โ€“ DAY 18

Topic: List Programs / Logic


๐Ÿ”น LIST PROGRAMS KYA HAIN? (WHAT)

List programs me hum real logic + conditions + loops use karke list ke upar kaam karte hain.


๐Ÿ”น KYON ZAROORI HAIN? (WHY)

  • Real-life data handling
  • Coding interviews
  • Strong logic building

๐Ÿ”น LIST PROGRAMS KAISE BANATE HAIN? (HOW)

  • Loop (for)
  • Conditions (if)
  • List methods

๐Ÿ“˜ DAY 18 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Sum of List Elements

numbers = [10, 20, 30]
total = 0
for n in numbers:
    total += n
print("Sum:", total)

๐Ÿ“Œ Loop se sum nikala


โœ… Example 2: Max Element

numbers = [5, 2, 9, 1]
print(max(numbers))

๐Ÿ“Œ max() largest value deta hai


โœ… Example 3: Min Element

numbers = [5, 2, 9, 1]
print(min(numbers))

๐Ÿ“Œ min() smallest value deta hai


โœ… Example 4: Count Even Numbers

numbers = [1, 2, 3, 4, 5]
count = 0
for n in numbers:
    if n % 2 == 0:
        count += 1
print("Even numbers:", count)

โœ… Example 5: Remove Duplicates

nums = [1, 2, 2, 3, 3]
unique = []

for n in nums:
    if n not in unique:
        unique.append(n)

print(unique)

๐Ÿ“Œ Duplicate remove kiye


โœ… Example 6: Reverse List

numbers = [1, 2, 3]
numbers.reverse()
print(numbers)

โœ… Example 7: Search Element

nums = [10, 20, 30]
if 20 in nums:
    print("Found")
else:
    print("Not Found")

โœ… Example 8: Multiply All Elements

numbers = [1, 2, 3]
result = 1
for n in numbers:
    result *= n
print("Product:", result)

โœ… Example 9: Separate Even & Odd

nums = [1, 2, 3, 4]
even = []
odd = []

for n in nums:
    if n % 2 == 0:
        even.append(n)
    else:
        odd.append(n)

print("Even:", even)
print("Odd:", odd)

โœ… Example 10: List from User Input

nums = []
for i in range(5):
    n = int(input("Enter number: "))
    nums.append(n)

print(nums)

๐Ÿ“ DAY 18 SUMMARY (Notes)

  • Loops list programs ka base hain
  • max(), min() helpful built-ins
  • Duplicates logic se remove hote hain
  • List data processing me powerful hai

๐Ÿง  DAY 18 PRACTICE (Homework)

  1. User list ka average nikalo
  2. List me second largest element find karo
  3. List ko ascending & descending me sort karo

๐Ÿ PYTHON โ€“ DAY 19

Topic: Tuples โ€“ Basics


๐Ÿ”น TUPLE KYA HOTI HAI? (WHAT)

Tuple ek ordered collection hoti hai jo list jaisi hoti hai,
lekin immutable hoti hai (change nahi hoti).

Example:
(10, 20, 30)
("apple", "banana")


๐Ÿ”น TUPLE KYON USE KARTE HAIN? (WHY)

  • Data ko safe (read-only) rakhne ke liye
  • Faster performance ke liye
  • Fixed data ke liye

๐Ÿ”น TUPLE KAISE BANATE HAIN? (HOW)

Tuple round brackets ( ) me banti hai.

tuple_name = (values)

๐Ÿ“˜ DAY 19 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Tuple

numbers = (10, 20, 30)
print(numbers)

โœ… Example 2: Single Element Tuple

t = (5,)
print(t)

๐Ÿ“Œ Comma zaroori hai


โœ… Example 3: Mixed Data Tuple

data = (1, "Python", 3.5)
print(data)

โœ… Example 4: Access Tuple Elements

fruits = ("apple", "banana", "mango")
print(fruits[1])

โœ… Example 5: Negative Indexing

fruits = ("apple", "banana", "mango")
print(fruits[-1])

โœ… Example 6: Tuple Length

items = ("pen", "book")
print(len(items))

โœ… Example 7: Loop Through Tuple

colors = ("red", "green", "blue")
for c in colors:
    print(c)

โœ… Example 8: Tuple Concatenation

t1 = (1, 2)
t2 = (3, 4)
print(t1 + t2)

โœ… Example 9: Tuple Repetition

t = (1, 2)
print(t * 3)

โœ… Example 10: Check Element Exists

nums = (10, 20, 30)
if 20 in nums:
    print("Found")

๐Ÿ“ DAY 19 SUMMARY (Notes)

  • Tuple ordered & immutable hoti hai
  • Indexing & slicing supported
  • Fixed data ke liye best
  • List se faster hoti hai

๐Ÿง  DAY 19 PRACTICE (Homework)

  1. Tuple me total elements count karo
  2. Tuple ke first & last element print karo
  3. Tuple se max & min element find karo

๐Ÿ PYTHON โ€“ DAY 20

Topic: Tuple Programs & Operations


๐Ÿ”น TUPLE PROGRAMS KYA HAIN? (WHAT)

Tuple programs me hum logic + loops + built-in functions ka use karke tuple ke data par kaam karte hain.


๐Ÿ”น KYON ZAROORI HAIN? (WHY)

  • Immutable data handling samajhne ke liye
  • Interview questions practice
  • Python data structures strong karne ke liye

๐Ÿ”น TUPLE PROGRAMS KAISE BANATE HAIN? (HOW)

  • Loop (for)
  • Built-in functions (max, min, sum)
  • Tuple unpacking

๐Ÿ“˜ DAY 20 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Sum of Tuple Elements

nums = (10, 20, 30)
print(sum(nums))

๐Ÿ“Œ sum() total nikalta hai


โœ… Example 2: Max Element

nums = (5, 2, 9, 1)
print(max(nums))

โœ… Example 3: Min Element

nums = (5, 2, 9, 1)
print(min(nums))

โœ… Example 4: Count Element

nums = (1, 2, 2, 3)
print(nums.count(2))

๐Ÿ“Œ Kitni baar value hai


โœ… Example 5: Index of Element

nums = (10, 20, 30)
print(nums.index(20))

โœ… Example 6: Tuple Unpacking

data = ("Python", 3.10)
lang, version = data
print(lang)
print(version)

๐Ÿ“Œ Values ko alag variables me todna


โœ… Example 7: Loop with Index

nums = (10, 20, 30)
for i in range(len(nums)):
    print(i, nums[i])

โœ… Example 8: Convert Tuple to List

t = (1, 2, 3)
lst = list(t)
lst.append(4)
print(lst)

๐Ÿ“Œ Modify karne ke liye list me convert


โœ… Example 9: Nested Tuple

data = ((1, 2), (3, 4))
print(data[1][0])

๐Ÿ“Œ Nested access


โœ… Example 10: Check All Elements Even

nums = (2, 4, 6)
all_even = True

for n in nums:
    if n % 2 != 0:
        all_even = False

print(all_even)

๐Ÿ“ DAY 20 SUMMARY (Notes)

  • Tuple immutable hoti hai
  • Built-ins se operations easy
  • Unpacking important concept
  • Modification ke liye list me convert

๐Ÿง  DAY 20 PRACTICE (Homework)

  1. Tuple ka average find karo
  2. Tuple me odd numbers count karo
  3. Tuple ko list me convert karke reverse karo

๐Ÿ PYTHON โ€“ DAY 21

Topic: Sets โ€“ Basics


๐Ÿ”น SET KYA HOTA HAI? (WHAT)

Set ek unordered collection hota hai jisme
โœ” Duplicate values allow nahi hoti
โœ” Indexing nahi hoti

Example:
{1, 2, 3}
{"apple", "banana"}


๐Ÿ”น SET KYON USE KARTE HAIN? (WHY)

  • Duplicate values remove karne ke liye
  • Mathematical operations ke liye
  • Fast membership checking ke liye

๐Ÿ”น SET KAISE BANATE HAIN? (HOW)

Set curly braces { } me banta hai.

set_name = {values}

๐Ÿ“˜ DAY 21 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Set

nums = {1, 2, 3}
print(nums)

๐Ÿ“Œ Order fixed nahi hota


โœ… Example 2: Duplicate Removed

nums = {1, 2, 2, 3}
print(nums)

๐Ÿ“Œ Duplicate automatically remove ho jaate hain


โœ… Example 3: Mixed Data Set

data = {1, "Python", 3.5}
print(data)

โœ… Example 4: Create Empty Set

s = set()
print(s)

๐Ÿ“Œ {} empty dictionary hoti hai, set nahi


โœ… Example 5: Loop Through Set

colors = {"red", "green", "blue"}
for c in colors:
    print(c)

โœ… Example 6: Add Element

nums = {1, 2}
nums.add(3)
print(nums)

โœ… Example 7: Remove Element

nums = {1, 2, 3}
nums.remove(2)
print(nums)

๐Ÿ“Œ Element na ho to error aata hai


โœ… Example 8: Safe Remove (discard)

nums = {1, 2, 3}
nums.discard(5)
print(nums)

๐Ÿ“Œ Error nahi aata


โœ… Example 9: Membership Check

nums = {10, 20, 30}
print(20 in nums)

โœ… Example 10: Set Length

items = {"pen", "book"}
print(len(items))

๐Ÿ“ DAY 21 SUMMARY (Notes)

  • Set unordered hota hai
  • Duplicate values allowed nahi
  • Indexing support nahi karta
  • Fast searching ke liye best

๐Ÿง  DAY 21 PRACTICE (Homework)

  1. List ko set me convert karke duplicates remove karo
  2. User se values leke set banao
  3. Set me element exist karta hai ya nahi check karo

๐Ÿ PYTHON โ€“ DAY 22

Topic: Set Methods & Operations


๐Ÿ”น SET METHODS KYA HAIN? (WHAT)

Set methods wo built-in functions hote hain jo sets par mathematical operations perform karte hain.


๐Ÿ”น SET KYON IMPORTANT HAI? (WHY)

  • Duplicate removal
  • Fast comparison
  • Real-life data filtering

๐Ÿ”น SET METHODS KAISE USE KARTE HAIN? (HOW)

set1.method(set2)

๐Ÿ“˜ DAY 22 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: union()

a = {1, 2, 3}
b = {3, 4, 5}
print(a.union(b))

๐Ÿ“Œ Dono sets ke unique elements


โœ… Example 2: intersection()

a = {1, 2, 3}
b = {2, 3, 4}
print(a.intersection(b))

๐Ÿ“Œ Common elements


โœ… Example 3: difference()

a = {1, 2, 3}
b = {2, 3}
print(a.difference(b))

๐Ÿ“Œ a me jo b me nahi


โœ… Example 4: symmetric_difference()

a = {1, 2, 3}
b = {3, 4}
print(a.symmetric_difference(b))

๐Ÿ“Œ Jo common nahi


โœ… Example 5: issubset()

a = {1, 2}
b = {1, 2, 3}
print(a.issubset(b))

โœ… Example 6: issuperset()

a = {1, 2, 3}
b = {1, 2}
print(a.issuperset(b))

โœ… Example 7: clear()

a = {1, 2, 3}
a.clear()
print(a)

โœ… Example 8: copy()

a = {1, 2}
b = a.copy()
print(b)

โœ… Example 9: Set from List

nums = [1, 2, 2, 3]
s = set(nums)
print(s)

โœ… Example 10: Frozen Set

fs = frozenset([1, 2, 3])
print(fs)

๐Ÿ“Œ Immutable set


๐Ÿ“ DAY 22 SUMMARY (Notes)

  • Set operations mathematical jaise hote hain
  • union, intersection common use
  • frozenset immutable hota hai
  • Duplicate handling me powerful

๐Ÿง  DAY 22 PRACTICE (Homework)

  1. Do sets ka common element find karo
  2. Set se duplicates remove karo
  3. Check karo ek set dusre ka subset hai ya nahi

๐Ÿ PYTHON โ€“ DAY 23

Topic: Dictionary โ€“ Basics


๐Ÿ”น DICTIONARY KYA HOTI HAI? (WHAT)

Dictionary ek keyโ€“value pair data structure hoti hai.
Har key unique hoti hai aur value kuch bhi ho sakti hai.

Example:

{"name": "Rahul", "age": 20}

๐Ÿ”น DICTIONARY KYON USE KARTE HAIN? (WHY)

  • Real-world data represent karne ke liye
  • Fast lookup ke liye
  • Structured data store karne ke liye

๐Ÿ”น DICTIONARY KAISE BANATE HAIN? (HOW)

Dictionary curly braces {} me banti hai.

dict_name = {key: value}

๐Ÿ“˜ DAY 23 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Dictionary

student = {"name": "Amit", "age": 21}
print(student)

โœ… Example 2: Access Value

student = {"name": "Amit", "age": 21}
print(student["name"])

๐Ÿ“Œ Key se value access hoti hai


โœ… Example 3: Using get()

print(student.get("age"))

๐Ÿ“Œ Safe access (error nahi aata)


โœ… Example 4: Add New Key

student["city"] = "Delhi"
print(student)

โœ… Example 5: Modify Value

student["age"] = 22
print(student)

โœ… Example 6: Remove Key

student.pop("city")
print(student)

โœ… Example 7: Loop Through Keys

for key in student:
    print(key)

โœ… Example 8: Loop Through Values

for value in student.values():
    print(value)

โœ… Example 9: Loop Through Items

for k, v in student.items():
    print(k, ":", v)

โœ… Example 10: Dictionary Length

print(len(student))

๐Ÿ“ DAY 23 SUMMARY (Notes)

  • Dictionary = keyโ€“value pair
  • Keys unique hoti hain
  • Fast data access
  • Mutable data structure

๐Ÿง  DAY 23 PRACTICE (Homework)

  1. Apni details dictionary me store karo
  2. Dictionary se kisi key ko delete karo
  3. Loop se keys aur values print karo

๐Ÿ PYTHON โ€“ DAY 24

Topic: Dictionary Methods & Operations


๐Ÿ”น DICTIONARY METHODS KYA HAIN? (WHAT)

Dictionary methods wo built-in functions hote hain jo dictionary ke data ko manage aur manipulate karte hain.


๐Ÿ”น DICTIONARY KYON IMPORTANT HAI? (WHY)

  • Fast searching
  • Structured data handling
  • Real-world applications (JSON, APIs)

๐Ÿ”น DICTIONARY METHODS KAISE USE KARTE HAIN? (HOW)

dict_name.method()

๐Ÿ“˜ DAY 24 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: keys()

student = {"name": "Amit", "age": 21}
print(student.keys())

๐Ÿ“Œ Saari keys deta hai


โœ… Example 2: values()

print(student.values())

๐Ÿ“Œ Saari values deta hai


โœ… Example 3: items()

print(student.items())

๐Ÿ“Œ Key-value pair return karta hai


โœ… Example 4: update()

student.update({"city": "Delhi"})
print(student)

๐Ÿ“Œ New data add ya existing update


โœ… Example 5: pop()

student.pop("age")
print(student)

๐Ÿ“Œ Specific key remove karta hai


โœ… Example 6: popitem()

student.popitem()
print(student)

๐Ÿ“Œ Last inserted item remove


โœ… Example 7: clear()

student.clear()
print(student)

๐Ÿ“Œ Dictionary empty ho jaati hai


โœ… Example 8: copy()

student = {"name": "Amit"}
new_student = student.copy()
print(new_student)

๐Ÿ“Œ Shallow copy banata hai


โœ… Example 9: fromkeys()

keys = ["name", "age"]
d = dict.fromkeys(keys, "NA")
print(d)

๐Ÿ“Œ Same default value assign karta hai


โœ… Example 10: Check Key Exists

student = {"name": "Amit"}
print("name" in student)

๐Ÿ“Œ True / False return karta hai


๐Ÿ“ DAY 24 SUMMARY (Notes)

  • Dictionary methods data manage karte hain
  • update() flexible method hai
  • pop() vs popitem() difference samjho
  • Real projects me dictionary ka heavy use hota hai

๐Ÿง  DAY 24 PRACTICE (Homework)

  1. Two dictionaries merge karo
  2. User se data leke dictionary banao
  3. Dictionary me kisi key ka existence check karo

๐Ÿ PYTHON โ€“ DAY 25

Topic: Dictionary Programs / Logic


๐Ÿ”น DICTIONARY PROGRAMS KYA HAIN? (WHAT)

Dictionary programs me hum logic + loops + conditions ka use karke real-life type problems solve karte hain.


๐Ÿ”น KYON ZAROORI HAIN? (WHY)

  • Real data handling
  • Interview questions
  • Python me mastery ke liye

๐Ÿ”น DICTIONARY PROGRAMS KAISE BANATE HAIN? (HOW)

  • for loop
  • if condition
  • Dictionary methods

๐Ÿ“˜ DAY 25 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Count Word Frequency

text = "python is easy and python is powerful"
words = text.split()
freq = {}

for w in words:
    freq[w] = freq.get(w, 0) + 1

print(freq)

๐Ÿ“Œ Words kitni baar aaye


โœ… Example 2: Student Marks Total

marks = {"Math": 80, "Eng": 70, "Sci": 90}
total = sum(marks.values())
print("Total:", total)

โœ… Example 3: Find Max Value Key

marks = {"Math": 80, "Eng": 70, "Sci": 90}
max_sub = max(marks, key=marks.get)
print(max_sub)

โœ… Example 4: Merge Two Dictionaries

d1 = {"a": 1}
d2 = {"b": 2}
d1.update(d2)
print(d1)

โœ… Example 5: Remove Keys with None

data = {"a": 10, "b": None, "c": 20}
clean = {}

for k, v in data.items():
    if v is not None:
        clean[k] = v

print(clean)

โœ… Example 6: Sort Dictionary by Keys

data = {"b": 2, "a": 1, "c": 3}
print(dict(sorted(data.items())))

โœ… Example 7: Check Value Exists

data = {"a": 10, "b": 20}
print(20 in data.values())

โœ… Example 8: Count Characters in String

text = "banana"
count = {}

for ch in text:
    count[ch] = count.get(ch, 0) + 1

print(count)

โœ… Example 9: Convert List to Dictionary

keys = ["name", "age"]
values = ["Amit", 21]
d = dict(zip(keys, values))
print(d)

โœ… Example 10: Nested Dictionary Access

student = {
    "name": "Amit",
    "marks": {"Math": 80, "Sci": 90}
}

print(student["marks"]["Math"])

๐Ÿ“ DAY 25 SUMMARY (Notes)

  • get() method safe & powerful
  • Dictionary real-life problems solve karti hai
  • Nested dictionaries important topic
  • Interview me frequently aata hai

๐Ÿง  DAY 25 PRACTICE (Homework)

  1. Sentence me har character ka count banao
  2. Student dictionary me highest marks subject find karo
  3. Dictionary ko ascending order me sort karo

๐Ÿ PYTHON โ€“ DAY 26

Topic: Functions โ€“ Basics


๐Ÿ”น FUNCTION KYA HOTA HAI? (WHAT)

Function ek block of code hota hai jo ek specific kaam karta hai aur
baar-baar reuse kiya ja sakta hai.

Example:
print() bhi ek function hai


๐Ÿ”น FUNCTION KYON USE KARTE HAIN? (WHY)

  • Code repeat hone se bachane ke liye
  • Program ko readable banane ke liye
  • Large problems ko small parts me todne ke liye

๐Ÿ”น FUNCTION KAISE BANATE HAIN? (HOW)

def function_name():
    code

๐Ÿ“˜ DAY 26 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Function

def greet():
    print("Hello Python")

greet()

๐Ÿ“Œ Function define aur call kiya


โœ… Example 2: Function with Parameter

def greet(name):
    print("Hello", name)

greet("Amit")

๐Ÿ“Œ Parameter value accept karta hai


โœ… Example 3: Function with Two Parameters

def add(a, b):
    print(a + b)

add(10, 20)

โœ… Example 4: Function with Return Value

def add(a, b):
    return a + b

result = add(5, 3)
print(result)

๐Ÿ“Œ return value wapas deta hai


โœ… Example 5: Function for Even Check

def is_even(n):
    if n % 2 == 0:
        return True
    else:
        return False

print(is_even(4))

โœ… Example 6: Function with Default Parameter

def greet(name="User"):
    print("Hello", name)

greet()
greet("Rahul")

โœ… Example 7: Function Calling Another Function

def square(n):
    return n * n

def show_square(x):
    print(square(x))

show_square(5)

โœ… Example 8: Function with Loop

def print_numbers():
    for i in range(1, 6):
        print(i)

print_numbers()

โœ… Example 9: Function for String Length

def string_length(text):
    return len(text)

print(string_length("Python"))

โœ… Example 10: Function with User Input

def add_numbers():
    a = int(input("Enter a: "))
    b = int(input("Enter b: "))
    print(a + b)

add_numbers()

๐Ÿ“ DAY 26 SUMMARY (Notes)

  • Function code reuse karta hai
  • def keyword se function banta hai
  • return value deta hai
  • Parameters optional hote hain

๐Ÿง  DAY 26 PRACTICE (Homework)

  1. Function banao jo number ka square return kare
  2. Function banao jo string reverse kare
  3. Function banao jo list ka sum nikale

๐Ÿ PYTHON โ€“ DAY 27

Topic: Function Arguments Types


๐Ÿ”น FUNCTION ARGUMENTS KYA HOTE HAIN? (WHAT)

Arguments wo values hoti hain jo function ko call karte time pass ki jaati hain.


๐Ÿ”น DIFFERENT TYPES KYON HAIN? (WHY)

Different situations me flexible functions banane ke liye.


๐Ÿ”น ARGUMENTS KAISE KAAM KARTE HAIN? (HOW)

Function definition me parameters aur function call me arguments hote hain.


๐Ÿ“˜ DAY 27 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Positional Arguments

def add(a, b):
    print(a + b)

add(10, 20)

๐Ÿ“Œ Order important hota hai


โœ… Example 2: Keyword Arguments

def info(name, age):
    print(name, age)

info(age=20, name="Amit")

๐Ÿ“Œ Order important nahi


โœ… Example 3: Default Arguments

def greet(name="User"):
    print("Hello", name)

greet()
greet("Rahul")

โœ… Example 4: Required Arguments

def square(n):
    print(n * n)

square(5)

๐Ÿ“Œ Value dena compulsory hai


โœ… Example 5: Variable Length Arguments (*args)

def total(*nums):
    print(sum(nums))

total(10, 20, 30)

๐Ÿ“Œ Multiple values accept karta hai


โœ… Example 6: Keyword Variable Length (**kwargs)

def details(**info):
    for k, v in info.items():
        print(k, ":", v)

details(name="Amit", age=21, city="Delhi")

โœ… Example 7: *args with Loop

def show(*values):
    for v in values:
        print(v)

show(1, 2, 3, "Python")

โœ… Example 8: Return with *args

def multiply(*nums):
    result = 1
    for n in nums:
        result *= n
    return result

print(multiply(2, 3, 4))

โœ… Example 9: Mixed Arguments

def info(name, *skills):
    print(name)
    for s in skills:
        print(s)

info("Amit", "Python", "SQL")

โœ… Example 10: Function with **kwargs Return

def get_info(**data):
    return data

print(get_info(name="Amit", age=21))

๐Ÿ“ DAY 27 SUMMARY (Notes)

  • Positional โ†’ order matters
  • Keyword โ†’ order free
  • Default โ†’ value optional
  • *args โ†’ multiple values
  • **kwargs โ†’ key-value pairs

๐Ÿง  DAY 27 PRACTICE (Homework)

  1. Function banao jo unlimited numbers ka average nikale
  2. Function banao jo student details **kwargs se le
  3. Function banao jo list ke elements print kare

๐Ÿ PYTHON โ€“ DAY 28

Topic: Lambda Functions & Recursion


๐Ÿ”น LAMBDA FUNCTION KYA HAI? (WHAT)

Lambda function ek small anonymous function hota hai
jisme ek hi line ka code hota hai.

Example:

lambda x: x*x

๐Ÿ”น LAMBDA KYON USE KARTE HAIN? (WHY)

  • Short logic ke liye
  • One-time use functions
  • Clean & readable code

๐Ÿ”น LAMBDA KAISE BANATE HAIN? (HOW)

lambda arguments: expression

๐Ÿ”น RECURSION KYA HAI? (WHAT)

Recursion me function khud ko call karta hai jab tak condition false na ho jaaye.


๐Ÿ”น RECURSION KYON USE KARTE HAIN? (WHY)

  • Repeated problems solve karne ke liye
  • Mathematical problems (factorial, fibonacci)

๐Ÿ”น RECURSION KAISE KAAM KARTA HAI? (HOW)

  • Base condition
  • Recursive call

๐Ÿ“˜ DAY 28 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple Lambda

square = lambda x: x * x
print(square(5))

โœ… Example 2: Lambda with Two Arguments

add = lambda a, b: a + b
print(add(10, 20))

โœ… Example 3: Lambda in map()

nums = [1, 2, 3]
result = list(map(lambda x: x * 2, nums))
print(result)

โœ… Example 4: Lambda in filter()

nums = [1, 2, 3, 4]
even = list(filter(lambda x: x % 2 == 0, nums))
print(even)

โœ… Example 5: Lambda in sorted()

data = [(1, 3), (2, 1), (4, 2)]
print(sorted(data, key=lambda x: x[1]))

โœ… Example 6: Simple Recursion

def show(n):
    if n == 0:
        return
    print(n)
    show(n - 1)

show(5)

โœ… Example 7: Factorial using Recursion

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n - 1)

print(factorial(5))

โœ… Example 8: Fibonacci using Recursion

def fib(n):
    if n <= 1:
        return n
    return fib(n-1) + fib(n-2)

print(fib(6))

โœ… Example 9: Sum of Numbers using Recursion

def sum_n(n):
    if n == 0:
        return 0
    return n + sum_n(n - 1)

print(sum_n(5))

โœ… Example 10: Check Even using Recursion

def is_even(n):
    if n == 0:
        return True
    if n == 1:
        return False
    return is_even(n - 2)

print(is_even(8))

๐Ÿ“ DAY 28 SUMMARY (Notes)

  • Lambda โ†’ one-line anonymous function
  • Recursion โ†’ function calling itself
  • Base condition very important
  • Complex problems easy ho jaate hain

๐Ÿง  DAY 28 PRACTICE (Homework)

  1. Lambda se square & cube banao
  2. Recursive function se reverse counting karo
  3. Fibonacci series first 5 numbers print karo

๐Ÿ PYTHON โ€“ DAY 29

Topic: File Handling โ€“ Basics


๐Ÿ”น FILE HANDLING KYA HAI? (WHAT)

File handling ka matlab hai file ko read, write, append karna using Python.


๐Ÿ”น FILE HANDLING KYON USE KARTE HAIN? (WHY)

  • Data permanently store karne ke liye
  • Logs, reports, records ke liye
  • Large data handle karne ke liye

๐Ÿ”น FILE KAISE OPEN KARTE HAIN? (HOW)

file = open("filename.txt", "mode")

Modes:

  • "r" โ†’ read
  • "w" โ†’ write
  • "a" โ†’ append

๐Ÿ“˜ DAY 29 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Write to File

f = open("data.txt", "w")
f.write("Hello Python")
f.close()

๐Ÿ“Œ File create / overwrite hoti hai


โœ… Example 2: Read from File

f = open("data.txt", "r")
print(f.read())
f.close()

โœ… Example 3: Append to File

f = open("data.txt", "a")
f.write("\nLearning File Handling")
f.close()

โœ… Example 4: Read Line by Line

f = open("data.txt", "r")
for line in f:
    print(line)
f.close()

โœ… Example 5: readline()

f = open("data.txt", "r")
print(f.readline())
f.close()

โœ… Example 6: readlines()

f = open("data.txt", "r")
print(f.readlines())
f.close()

โœ… Example 7: Using with Statement

with open("data.txt", "r") as f:
    print(f.read())

๐Ÿ“Œ Auto close ho jaati hai file


โœ… Example 8: Write Multiple Lines

lines = ["Python\n", "File\n", "Handling\n"]
with open("data.txt", "w") as f:
    f.writelines(lines)

โœ… Example 9: Check File Exists (Exception)

try:
    f = open("test.txt", "r")
    print(f.read())
except:
    print("File not found")

โœ… Example 10: Count Lines in File

count = 0
with open("data.txt", "r") as f:
    for line in f:
        count += 1

print("Lines:", count)

๐Ÿ“ DAY 29 SUMMARY (Notes)

  • File handling permanent storage ke liye
  • Modes samajhna zaroori hai
  • with safest way hai
  • Read & write dono important

๐Ÿง  DAY 29 PRACTICE (Homework)

  1. File me apna naam aur age store karo
  2. File se words count karo
  3. File me data append karo

๐Ÿ PYTHON โ€“ DAY 30

Topic: Exception Handling


๐Ÿ”น EXCEPTION KYA HOTI HAI? (WHAT)

Exception ek runtime error hota hai jo program ke execution ko rok deta hai
agar usko handle na kiya jaye.

Example:

  • ZeroDivisionError
  • ValueError
  • FileNotFoundError

๐Ÿ”น EXCEPTION HANDLING KYON ZAROORI HAI? (WHY)

  • Program crash hone se bachane ke liye
  • User-friendly error messages ke liye
  • Real-world applications me stability ke liye

๐Ÿ”น EXCEPTION HANDLING KAISE KARTE HAIN? (HOW)

try:
    risky code
except:
    error handling

๐Ÿ“˜ DAY 30 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Simple try-except

try:
    print(10 / 0)
except:
    print("Error occurred")

๐Ÿ“Œ Program crash nahi hoga


โœ… Example 2: Specific Exception

try:
    print(10 / 0)
except ZeroDivisionError:
    print("Cannot divide by zero")

โœ… Example 3: ValueError

try:
    num = int("abc")
except ValueError:
    print("Invalid conversion")

โœ… Example 4: Multiple Except

try:
    a = int(input("Enter number: "))
    print(10 / a)
except ValueError:
    print("Enter valid number")
except ZeroDivisionError:
    print("Cannot divide by zero")

โœ… Example 5: else Block

try:
    a = int(input("Enter number: "))
    print(10 / a)
except:
    print("Error")
else:
    print("No error occurred")

๐Ÿ“Œ else tab chalta hai jab error na ho


โœ… Example 6: finally Block

try:
    print(10 / 2)
except:
    print("Error")
finally:
    print("Always executed")

โœ… Example 7: File Handling Exception

try:
    f = open("abc.txt", "r")
    print(f.read())
except FileNotFoundError:
    print("File not found")

โœ… Example 8: Custom Error Message

try:
    age = int(input("Enter age: "))
    if age < 18:
        raise ValueError
except ValueError:
    print("Age must be 18 or above")

โœ… Example 9: Catch All Exceptions

try:
    print(x)
except Exception as e:
    print("Error:", e)

โœ… Example 10: Loop with Exception Handling

while True:
    try:
        n = int(input("Enter number: "))
        print("You entered:", n)
        break
    except:
        print("Invalid input, try again")

๐Ÿ“ DAY 30 SUMMARY (Notes)

  • Exception = runtime error
  • try block me risky code
  • except error handle karta hai
  • finally always execute hota hai
  • Real projects me must topic

๐Ÿง  DAY 30 PRACTICE (Homework)

  1. User se number leke divide karo with exception handling
  2. File open karte time error handle karo
  3. Loop banao jo correct input aane tak chale

๐Ÿ PYTHON โ€“ DAY 31

Topic: OOPs โ€“ Object Oriented Programming (Basics)


๐Ÿ”น OOPs KYA HAI? (WHAT)

OOPs ek programming paradigm hai jisme hum code ko objects & classes me organize karte hain.

Real life example:
Car โ†’ object
Car ka design โ†’ class


๐Ÿ”น OOPs KYON USE KARTE HAIN? (WHY)

  • Code reusable hota hai
  • Security & data hiding milta hai
  • Large projects easy ban jaate hain

๐Ÿ”น OOPs KAISE KAAM KARTA HAI? (HOW)

OOPs 4 pillars par based hai:

  1. Encapsulation
  2. Abstraction
  3. Inheritance
  4. Polymorphism

๐Ÿ“˜ DAY 31 โ€“ 10 EXAMPLES (WITH EXPLANATION)


โœ… Example 1: Create Class & Object

class Student:
    pass

s1 = Student()
print(s1)

๐Ÿ“Œ Class ek blueprint hoti hai, object real entity


โœ… Example 2: Class with Variable

class Student:
    name = "Amit"

s1 = Student()
print(s1.name)

โœ… Example 3: Class with Method

class Student:
    def greet(self):
        print("Hello Student")

s1 = Student()
s1.greet()

โœ… Example 4: Constructor (__init__)

class Student:
    def __init__(self, name):
        self.name = name

s1 = Student("Rahul")
print(s1.name)

โœ… Example 5: Multiple Attributes

class Student:
    def __init__(self, name, age):
        self.name = name
        self.age = age

s1 = Student("Amit", 20)
print(s1.name, s1.age)

โœ… Example 6: Method Using Attributes

class Student:
    def __init__(self, name):
        self.name = name

    def show(self):
        print("Name:", self.name)

s1 = Student("Neha")
s1.show()

โœ… Example 7: Update Attribute

s1.name = "Riya"
print(s1.name)

โœ… Example 8: Delete Attribute

del s1.name

โœ… Example 9: Class for Calculator

class Calc:
    def add(self, a, b):
        return a + b

c = Calc()
print(c.add(10, 20))

โœ… Example 10: Object Count

class Test:
    count = 0
    def __init__(self):
        Test.count += 1

t1 = Test()
t2 = Test()
print(Test.count)

๐Ÿ“ DAY 31 SUMMARY (Notes)

  • Class = blueprint
  • Object = instance
  • self current object ko refer karta hai
  • __init__ constructor hota hai

๐Ÿง  DAY 31 PRACTICE

  1. Class banao Employee ke liye
  2. Constructor me name & salary store karo
  3. Method se details print karo