Complete Python Notes in Hinglish
Chapter 1: Introduction to Python
Python Kya Hai?
Python ek high-level, interpreted aur general-purpose programming language hai. Yeh
simple syntax aur readability ke liye famous hai. Beginners ke liye best programming
language mana jata hai.
Features of Python:
- Easy to learn and write
- Open-source and free
- Interpreted language
- High-level language
- Portable
- Extensive standard libraries
- Object-Oriented and Functional Programming support
Chapter 2: Installing Python and Running Code
Install Python:
1. Visit: https://python.org
2. Download latest version (Recommended: Python 3.10 or above)
3. Install and check 'Add to PATH' option
Run Code:
- Use IDLE (Python ka built-in editor)
- Use terminal or command prompt:
python filename.py
- Use Online Editors: Replit, Jupyter Notebook, etc.
Chapter 3: Variables & Data Types
Variables:
Variable ek container hota hai jisme data store hota hai.
Data Types in Python:
int – Integer (e.g., 10)
float – Decimal number (e.g., 3.14)
str – String/Text (e.g., "Python")
bool – Boolean (True/False)
list – Ordered, mutable collection (e.g., [1, 2, 3])
tuple – Ordered, immutable collection (e.g., (1, 2, 3))
dict – Key-value pairs (e.g., {"a": 1, "b": 2})
set – Unordered unique elements (e.g., {1, 2, 3})
Chapter 4: Typecasting in Python
Typecasting ka matlab hota hai ek data type ko doosre mein convert karna.
Common Functions:
int("10") → 10
float("3.14") → 3.14
str(100) → "100"
list("abc") → ["a", "b", "c"]
Chapter 5: Python Operators
Arithmetic Operators: +, -, *, /, //, %, **
Comparison Operators: ==, !=, >, <, >=, <=
Logical Operators: and, or, not
Assignment Operators: =, +=, -=, *=, /=, //=, %=, **=
Identity Operators: is, is not
Membership Operators: in, not in
Chapter 6: Conditional Statements (if, elif, else)
Syntax:
if condition:
# block
elif condition2:
# block
else:
# block
Chapter 7: Loops in Python (for, while)
for loop:
for i in range(5):
print(i)
while loop:
i=0
while i < 5:
print(i)
i += 1
Chapter 8: Functions in Python
Function Definition:
def greet(name):
print("Hello", name)
Function Call:
greet("Aman")
return Statement:
def add(x, y):
return x + y
Chapter 9: Python Lists
my_list = [1, 2, 3]
print(my_list[0])
my_list.append(4)
my_list.remove(2)
my_list.sort()
Chapter 10: Dictionary
student = {"name": "Aman", "age": 20}
print(student["name"])
Chapter 11: Tuples & Sets
Tuple: t = (1, 2, 3)
Set: s = {1, 2, 3}, s.add(4)
Chapter 12: String Handling
s = "Hello Python"
print(s.upper())
print(s.lower())
print(s.replace("Python", "World"))
Chapter 13: File Handling
Open File:
f = open("data.txt", "r")
data = f.read()
f.close()
Write File:
f = open("data.txt", "w")
f.write("Hello")
f.close()
Chapter 14: Object Oriented Programming (OOP)
class Person:
def __init__(self, name):
self.name = name
def greet(self):
print("Hello", self.name)
p = Person("Aman")
p.greet()
Chapter 15: Exception Handling
try:
a=5/0
except ZeroDivisionError:
print("Can't divide by zero")
finally:
print("Done")
Chapter 16: Python Projects
📌 Project 1: Calculator App
def add(x, y): return x + y
def sub(x, y): return x - y
def mul(x, y): return x * y
def div(x, y): return x / y if y != 0 else "Cannot divide by 0"
choice = input("Choose: 1-Add 2-Sub 3-Mul 4-Div: ")
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
if choice == '1': print(add(a, b))
elif choice == '2': print(sub(a, b))
elif choice == '3': print(mul(a, b))
elif choice == '4': print(div(a, b))
else: print("Invalid")
📌 Project 2: Number Guessing Game
import random
number = random.randint(1, 100)
while True:
guess = int(input("Guess a number between 1 and 100: "))
if guess < number:
print("Too low!")
elif guess > number:
print("Too high!")
else:
print("Congratulations! You guessed it right.")
break
📚 Ye complete Python Hinglish notes hain. Inke baad aapko aur kisi book ya video ki zarurat
nahi padegi.