Python
Python is readable, batteries-included, and everywhere — from quick scripts to data science. This is the core you need to start.
Python’s whole design goal is readability. Blocks are defined by indentation rather than braces, and the standard library is enormous, so a lot of what you want to do is already written.
Values and variables
name = "Ada" # str
age = 36 # int
height = 1.68 # float
is_admin = False # bool
items = ["a", "b"] # list
person = {"id": 1} # dict
You do not declare types — a variable just points at a value, and can later point at a different one.
Control flow
if age >= 18:
print("adult")
elif age >= 13:
print("teen")
else:
print("child")
for item in items:
print(item)
n = 0
while n < 3:
n += 1
The colon and the indentation are not optional — they are the block syntax.
Functions
def greet(name, excited=False):
msg = f"Hello, {name}"
return msg + "!" if excited else msg
print(greet("Ada")) # Hello, Ada
print(greet("Ada", True)) # Hello, Ada!
That f"..." is an f-string — the cleanest way to drop values into text.
Collections you will use constantly
- list — ordered, changeable:
nums = [3, 1, 2]; nums.sort() - dict — key/value pairs:
user["name"] - set — unique values:
set([1, 1, 2])is{1, 2} - tuple — ordered, fixed:
point = (3, 4)
A list comprehension
A Python idiom worth learning early — build a list in one expression:
squares = [n * n for n in range(5)] # [0, 1, 4, 9, 16]
evens = [n for n in range(10) if n % 2 == 0]
Next step: once comfortable, look at modules (
import), virtual environments (python -m venv), and pip for installing packages.