pythonANYprintbasics
python
print("Hello, world!")Core Python syntax, control flow, operators, collections, and everyday language patterns.
Core syntax and invocation patterns.
print("Hello, world!")x, y = 10, 20a, b = b, aname = input("Name: ")python -c "print(sum(range(10)))"python -m http.server 8000Arithmetic and boolean expression patterns.
quotient = 7 // 3remainder = 7 % 3power = 2 ** 8is_between = 1 < x < 10username = supplied_name or "anonymous"label = "adult" if age >= 18 else "minor"Control flow tools from the Python tutorial and language reference.
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
else:
grade = "C"for name in names:
print(name)for idx, value in enumerate(items, start=1):
print(idx, value)for name, score in zip(names, scores):
print(name, score)while queue:
item = queue.pop(0)
print(item)for item in items:
if item == target:
print("found")
break
else:
print("not found")match status:
case 200:
message = "ok"
case 404:
message = "not found"
case _:
message = "other"Common core data structures.
items = [1, 2, 3]point = (10, 20)tags = {"python", "api", "cli"}user = {"id": 1, "name": "Ada"}if "python" in tags:
print("present")first, *middle, last = values