💻 Programming

Python Programming Basics

Last updated: 2025-09-25 12:47:03

Python Programming Fundamentals

Python is a versatile, high-level programming language known for its simplicity and readability.

Variables and Data Types

# Basic data types
name = "John"  # String
age = 25       # Integer
height = 5.9   # Float
is_student = True  # Boolean

# Lists and dictionaries
fruits = ["apple", "banana", "orange"]
person = {"name": "Alice", "age": 30}

Control Structures

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

# Loops
for fruit in fruits:
    print(fruit)

while age > 0:
    age -= 1

Functions

def greet(name):
    return f"Hello, {name}!"

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

result = add(5, 3)  # Returns 8