Python Complete Guide 🐍

Powerful Language for AI, Web & Automation

1. What is Python?

Python is a simple, powerful programming language used in web development, AI, data science, automation, and more.

2. Hello World

print("Hello Python")

3. Variables

name = "Sasank"
age = 18
pi = 3.14

4. If-Else

age = 18

if age >= 18:
    print("Adult")
else:
    print("Minor")

5. Loops

for i in range(5):
    print(i)

6. Functions

def add(a, b):
    return a + b

print(add(2, 3))

7. Lists

numbers = [1, 2, 3, 4]

for n in numbers:
    print(n)

8. Dictionary

user = {
    "name": "Sasank",
    "role": "Developer"
}

print(user["name"])

9. OOP in Python

class Car:
    def __init__(self, model):
        self.model = model

    def drive(self):
        print("Car is running")

c = Car("BMW")
c.drive()

10. File Handling

file = open("data.txt", "w")
file.write("Hello Python")
file.close()

11. Real Use Cases