Introduction to Python

1/7/2025

Introduction to Python

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

Why Python?

  • Easy to learn: Clean, readable syntax
  • Versatile: Web, data science, AI, automation
  • Large ecosystem: Thousands of libraries
  • Active community: Excellent documentation and support

Getting Started

Check your Python version:

bash
python --version
# or
python3 --version

Hello World

python
print("Hello, World!")

Variables and Types

python
# Numbers
age = 25
price = 19.99

# Strings
name = "Python"
message = 'Hello'

# Booleans
is_active = True

# Lists
fruits = ["apple", "banana", "cherry"]

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

Type Hints (Python 3.5+)

python
def greet(name: str) -> str:
    return f"Hello, {name}!"

age: int = 25
names: list[str] = ["Alice", "Bob"]