๐ 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 linesepโ separatorendโ line ending control
๐ PRACTICE (Homework)
- Apna naam aur city print karo
- 3 favourite subjects print karo
- 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 name20โ integer valueprint(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)
- Apna naam, age aur college variable me store karo
- Do numbers ka multiplication variable se karo
- 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 numberstrโ 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:
astring haibint hai- Pehle
bkostr()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)
- Ek int ko float me convert karo
- User se number input leke uska square nikalo
- 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:
numstring 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)
- User se 3 numbers input leke average nikalo
- User se naam aur age input leke print karo
- 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)
- User se 2 numbers input leke sab arithmetic operations karo
- Check karo number even ya odd (
%) - 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)
ifcondition 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)
- User se number input leke positive check karo
- User se marks input leke pass check karo
- 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-elsetwo 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)
- User se number input leke even/odd check karo
- User se marks input leke pass/fail check karo
- 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-elsemultiple 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)
- User se marks input leke grade system banao
- User se number input leke positive/negative/zero check karo
- 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)
forloop repetition ke liye use hota hairange(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 se 20 tak numbers print karo
- 1 se 10 tak even numbers ka sum nikalo
- 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)
whileloop condition based hota hai- Counter update zaroori hai
breakloop tod deta haicontinueek iteration skip karta hai- Galat condition se infinite loop ban sakta hai
๐ง DAY 10 PRACTICE (Homework)
- User se number input leke uska factorial nikalo
- While loop se table print karo
- 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)
- 4ร4 star pattern banao
- User se number leke triangle pattern banao
- 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)
- User se rows input leke pyramid banao
- Number pyramid banao
- 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)
- Apna naam string me store karke letters print karo
- User se string input leke length print karo
- 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)
- User se name input leke capital me print karo
- User se sentence leke word count karo
- Email id
.comse 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)
- User input leke palindrome check karo
- User input ka reverse print karo
- 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)
- User se 5 numbers input leke list banao
- List ka first aur last element print karo
- 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โ addremove,popโ deletesort,reverseโ arrange- List mutable hoti hai
๐ง DAY 17 PRACTICE (Homework)
- User se numbers input leke list sort karo
- List me duplicate elements count karo
- 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)
- User list ka average nikalo
- List me second largest element find karo
- 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)
- Tuple me total elements count karo
- Tuple ke first & last element print karo
- 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)
- Tuple ka average find karo
- Tuple me odd numbers count karo
- 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)
- List ko set me convert karke duplicates remove karo
- User se values leke set banao
- 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,intersectioncommon usefrozensetimmutable hota hai- Duplicate handling me powerful
๐ง DAY 22 PRACTICE (Homework)
- Do sets ka common element find karo
- Set se duplicates remove karo
- 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)
- Apni details dictionary me store karo
- Dictionary se kisi key ko delete karo
- 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 haipop()vspopitem()difference samjho- Real projects me dictionary ka heavy use hota hai
๐ง DAY 24 PRACTICE (Homework)
- Two dictionaries merge karo
- User se data leke dictionary banao
- 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)
forloopifcondition- 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)
- Sentence me har character ka count banao
- Student dictionary me highest marks subject find karo
- 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
defkeyword se function banta haireturnvalue deta hai- Parameters optional hote hain
๐ง DAY 26 PRACTICE (Homework)
- Function banao jo number ka square return kare
- Function banao jo string reverse kare
- 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)
- Function banao jo unlimited numbers ka average nikale
- Function banao jo student details **kwargs se le
- 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)
- Lambda se square & cube banao
- Recursive function se reverse counting karo
- 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
withsafest way hai- Read & write dono important
๐ง DAY 29 PRACTICE (Homework)
- File me apna naam aur age store karo
- File se words count karo
- 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
tryblock me risky codeexcepterror handle karta haifinallyalways execute hota hai- Real projects me must topic
๐ง DAY 30 PRACTICE (Homework)
- User se number leke divide karo with exception handling
- File open karte time error handle karo
- 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:
- Encapsulation
- Abstraction
- Inheritance
- 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
selfcurrent object ko refer karta hai__init__constructor hota hai
๐ง DAY 31 PRACTICE
- Class banao Employee ke liye
- Constructor me name & salary store karo
- Method se details print karo


