The versatile language
Python is excellent for scripts, AI, data, and backends. Easy to read and learn.
Installation
| System | Command |
|---|---|
| macOS | brew install python |
| Windows | winget install Python.Python.3 |
| Linux | Already installed |
# Verify
python3 --version
uv: The modern manager
uv is the new Python package manager (10x faster than pip).
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create project
uv init my-project
cd my-project
# Add dependency
uv add requests
# Run
uv run python main.py
Basic concepts
Variables
name = "Ana"
age = 25
is_active = True
Functions
def greet(name: str) -> str:
return f"Hello, {name}!"
# Call
message = greet("Ana")
Lists
fruits = ["apple", "pear", "grape"]
# List comprehension
uppercase = [f.upper() for f in fruits]
# Filter
long_ones = [f for f in fruits if len(f) > 4]
Dictionaries
user = {
"name": "Ana",
"age": 25,
"email": "ana@email.com"
}
print(user["name"])
Virtual environments
# With uv (recommended)
uv venv
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
# With traditional venv
python3 -m venv .venv
Practice
Useful links
- ๐ Python Docs
- ๐ uv Docs