Python_Complete_Notes_Hinglish (2)
Python_Complete_Notes_Hinglish (2)
Features of Python:
- Easy to learn and write
- Interpreted language
- High-level language
- Portable
Install Python:
1. Visit: https://python.org
Run Code:
- Use IDLE (Python ka built-in editor)
python filename.py
Variables:
Variable ek container hota hai jisme data store hota hai.
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"
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:
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
print(student["name"])
Chapter 11: Tuples & Sets
Tuple: t = (1, 2, 3)
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:
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:
finally:
print("Done")
Chapter 16: Python Projects
else: print("Invalid")
import random
while True:
guess = int(input("Guess a number between 1 and 100: "))
print("Too low!")
print("Too high!")
else:
break
📚 Ye complete Python Hinglish notes hain. Inke baad aapko aur kisi book ya video ki zarurat
nahi padegi.