Basic concepts and examples for Python programming.
sudo apt update
sudo apt install python3 python3-pipbrew install python- Variable β a container for storing data.
- Function β reusable block of code.
- List β ordered, mutable collection.
- Tuple β ordered, immutable collection.
- Dictionary β key-value pairs.
- Loop β repeat a block of code.
- Condition β branching logic (if/else).
- Module β file containing Python definitions.
print("Hello, world!")name = "Anna"
age = 40
height = 1.65colors = ["red", "green", "blue"]
colors.append("purple")person = {"name": "Anna", "age": 40}
print(person["name"])def greet(name):
return f"Hello, {name}!"
print(greet("Anna"))if age > 18:
print("Adult")
else:
print("Minor")for color in colors:
print(color)- Working with files (
open,read,write) - Exception handling (
try,except) - Using external libraries (
pip install) - Virtual environments (
venv) - Object-Oriented Programming (OOP)
- Practice short scripts daily.
- Use Python Tutor (pythontutor.com) to visualize code.
- Try small challenges on sites like LeetCode, HackerRank, or Replit.