Python Master Guide
1. Introduction to Python
- Python is an interpreted, dynamically typed, high-level language.
print("Hello, Rohith Ji")
2. Variables & Data Types
age = 21
name = "Rohith"
is_king = True
3. Operators & Control Flow
if age > 18:
print("Adult")
else:
print("Minor")
4. Loops
for i in range(1, 6):
print(i)
5. Lists, Tuples, Dictionaries
lst = [1, 2, 3]
tup = (4, 5)
d = {"name": "Rohith"}
6. Functions
def add(a, b):
return a + b
7. OOP in Python
class Animal:
def sound(self):
print("Animal sound")
class Dog(Animal):
def sound(self):
print("Bark")
8. Exception Handling
try:
x = 10 / 0
except Exception as e:
print("Error:", e)
9. File Handling
with open("data.txt", "w") as f:
f.write("Hello, Rohith!")