Python Basics

Variables and Data Types

# Variables
name = "Alice"
age = 25
height = 5.6
is_student = True

# Lists
fruits = ["apple", "banana", "orange"]
numbers = [1, 2, 3, 4, 5]

# Dictionaries
person = {"name": "Bob", "age": 30}

Control Flow

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

# For loops
for fruit in fruits:
    print(fruit)

# While loops
count = 0
while count < 5:
    print(count)
    count += 1

Basic Operations

# String operations
greeting = "Hello " + name
print(f"Welcome, {name}!")

# List operations
fruits.append("grape")
print(len(fruits))

# Dictionary operations
person["city"] = "New York"
print(person.get("name"))