Posts

Showing posts from July, 2025

Python – Class & Objects

🔷 Python – Class & Objects (Easy Hinglish Notes) 🔸 Class kya hoti hai? Class ek design hoti hai — blueprint jiske base par hum objects banate hain. Example: Car ek class hai — lekin actual car (Maruti, Honda) object hai. 🔸 Object kya hota hai? Object class ka real example hota hai — jiske paas properties (data) aur functions (methods) hote hain. 🔸 Syntax of Class and Object: class ClassName: def __init__(self): # constructor print("Object bana") # object create karna obj = ClassName() 🔸 Example 1 – Simple Class: class Student: def __init__(self): print("Student object created") s1 = Student() 🟢 Output : Student object created 🔸 Example 2 – Class with Attributes: class Student: def __init__(self, name, marks): self.name = name self.marks = marks def show(self): print("Name:", self.name) print("Marks:", self.marks) s1 = Student("Navgh...

Python Function

🔷 Python Function – Notes (Very Easy Hinglish) 🔸 Function kya hota hai? Function ek code ka group hota hai jisko baar-baar use kar sakte hain bina baar-baar likhe. 🔸 Syntax of Function: def function_name(): # yeh kaam karega jab function call hoga 🔸 Example: def greet(): print("Hello! Welcome to Python.") greet() # function ko call kiya 🟢 Output: Hello! Welcome to Python. 🔸 Function with Parameters: def add(a, b): print("Sum is:", a + b) add(3, 4) 🟢 Output: Sum is: 7 🔸 Function with Return Value: def square(x): return x * x result = square(5) print("Square is:", result) 🟢 Output: Square is: 25 🟨 Practice Exercises with Solution ✅ Exercise 1: Q. Ek function banao jo "Good Morning" print kare. def wish(): print("Good Morning!") wish() ✅ Exercise 2: Q. Ek function banao jo 2 numbers ka sum return kare. def sum_two_numbers(a, b): return a + b print("Total:",...
🧠 Python If-Else Statement – Notes in Simple Hinglish ➤ if statement if condition: # agar condition true ho to yeh chalega Example: age = 18 if age >= 18: print("You are eligible to vote.") ➤ if-else statement if condition: # true else: # false Example: marks = 35 if marks >= 33: print("Pass") else: print("Fail") ➤ if-elif-else if condition1: # true elif condition2: # true else: # all false Example: num = 0 if num > 0: print("Positive") elif num < 0: print("Negative") else: print("Zero") 🔁 Python For Loop – Notes in Simple Hinglish for variable in range(start, end): # loop chalega ➤ Basic Example: for i in range(5): print(i) Output: 0 1 2 3 4 ➤ Using range(start, end, step): for i in range(1, 11, 2): print(i) Output: 1 3 5 7 9 ✅ Practice Exercises with Solutions Q1. Ek number input lo. Agar vo even ho to "Even" pr...