Python Complete Guide 🐍

Beginner → Advanced + Code Examples

1. Introduction

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

print("Hello Python")

2. Variables

name = "Sasank"
age = 18
print(name, age)

3. Data Types

x = 10        # int
y = 3.5       # float
z = "hello"   # string
flag = True   # boolean

4. Conditions

age = 18

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

5. Loops

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

6. Functions

def greet(name):
    return "Hello " + name

print(greet("Sasank"))

7. Lists

arr = [1,2,3,4]

for i in arr:
    print(i)

8. Dictionary

user = {
    "name": "Sasank",
    "age": 18
}

print(user["name"])

9. OOP (Class)

class Person:
    def __init__(self, name):
        self.name = name

p = Person("Sasank")
print(p.name)

10. File Handling

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

11. Modules

import math

print(math.sqrt(25))

12. Mini Project Idea

# Simple calculator
a = 10
b = 5

print(a + b)
print(a - b)