Variables and types — the stuff every script is built on top of.
print() shows something on the screen. Write the word print, then parentheses, then whatever you want shown, inside them.
print("Hello")
Print the word Hello.
print("Hello") → HelloPrint your name as text, e.g. "Sam".
print("Sam") → SamText (words, sentences, an email) needs quotes around it. Numbers don't.
print("Hello") # text — quotes
print(10) # number — no quotes
Print the number 10 (no quotes — it's a number).
print(10) → 10Print the number 3.99 (a decimal, still no quotes).
print(3.99) → 3.99A variable is a name you attach to a value, so you can use it again later instead of retyping it. Think of it like a labeled jar: apples = 10 makes a jar labeled apples, with 10 inside.
apples = 10
print(apples)
You have 10 apples. Store that in a variable called apples, then print it.
apples = 10
print(apples) → 10Store a user's email, "jrivera@example.com", in email, then print it.
email = "jrivera@example.com"
print(email)Coffee costs $3.99. Store it in price, then print it.
price = 3.99
print(price) → 3.99 — no $, no quotes, it's a number.Store the text "IT" in department, then print it.
department = "IT"
print(department)Store whether a light is on (True) in light_on, then print it.
light_on = True
print(light_on)What if you print a name nobody ever put in a jar? print(Sam) — no quotes. What happens?
NameError: name 'Sam' is not definedNo jar labeled Sam exists — nobody wrote Sam = ... anywhere. Python looked, found nothing, and stopped instead of guessing.
Open problems/01_create.py and do all 5 problems locally before moving on.
The same name can point at a new value later — it's not locked to the first thing you gave it.
apples = 10
apples = 7 # you ate 3 — apples now holds a different value
apples = 10, then you eat 3. Reassign to 7. Print old, then new.
apples = 10
print(apples)
apples = 7
print(apples) → 10 then 7price = 3.99, on sale for 2.99. Reassign, print old then new.
3.99 then 2.99status = "ACTIVE", account gets suspended. Reassign to "SUSPENDED", print both.
ACTIVE then SUSPENDEDlight_on = True, then turned off. Reassign to False, print both.
True then Falsecount = 1, reassign twice in a row (to 2, then 3). Print only the final value.
3Open problems/02_reassign.py and do all 5 problems locally.
Every value has a type. type() works just like print() — a name, parentheses, and what you want checked inside.
print(type("hello")) # <class 'str'>
print(type(42)) # <class 'int'>
Ignore the word class in that output for now — just read the part after it (str, int) to know the type.
Print the type of apples (10).
<class 'int'>Print the type of email ("jrivera@example.com").
<class 'str'>Print the type of price (3.99).
<class 'float'>Print the type of light_on (True).
<class 'bool'>print(type(10 / 2)) — division always returns a decimal type, even if the answer is whole.
<class 'float'>Open problems/03_type_check.py and do all 5 problems locally.
A string is text. Glue two strings together with +.
user_id = "00u001"
print(user_id + "!") # "00u001!"
print(len(user_id)) # 6 — len() counts the characters
first = "Julio", last = "Rivera". Combine into "Julio Rivera" using + (don't forget the space).
first + " " + lastPrint first + last (no space), then first + " " + last (with space).
JulioRivera then Julio RiveraPrint a string, then print its len() on the next line.
jrivera@example.com → 19" jrivera@example.com " has hidden spaces at both ends. Print its len().
23 — larger than the visible email alone (19), because of the hidden whitespace.Print "IT" + "-" + "001" as one combined string.
IT-001Open problems/04_string.py and do all 6 problems locally.
No quotes, no decimal point. Used for counts — not for things like IDs, even when an ID looks numeric.
apples = 10. Print it.
10You buy 5 more apples. Print apples + 5.
15You eat 4 apples. Print apples - 4.
610 apples split into groups of 3. print(10 // 3) — how many full groups?
3Same split — print(10 % 3) — how many left over?
1Open problems/05_integer.py — 6 problems, #6 is a checkpoint combining sub-skills 1–5.
Numbers with a decimal point. Mixing a whole number and a decimal (3 + 0.5) produces a decimal result — the more precise type wins.
price = 3.99. Print it.
3.99Print 3 + 0.5, then type(3 + 0.5) on the next line.
3.5 then <class 'float'>Print 10 / 4 — dividing two whole numbers still gives a decimal.
2.5Print round(3.14159, 1).
3.1Like a two-line receipt: print price, then print the text Coffee on the next line (two separate prints).
3.99 then CoffeeOpen problems/06_float.py and do all 6 problems locally.
True or False — only two values. But bool() also tells you how other values act: empty things count as False, non-empty things count as True. This is called truthiness.
is_active = True
print(bool("")) # False — empty text
print(bool("hi")) # True — non-empty text
print(bool(0)) # False — zero
light_on = True. Print it, then print type(light_on).
True then <class 'bool'>Print bool(""), then bool("x").
False then TruePrint bool(0), then bool(1).
False then TruePrint bool([]), then bool(["Engineering"]).
False then Trueprint(bool(None))
FalseOpen problems/07_boolean.py and do all 7 problems locally.
None means "there is deliberately nothing here." Not 0, not "", not missing — the value is nothing.
== asks "are these two things equal?" and answers with True or False — same idea as bool(), just comparing two things instead of checking one.
last_login = None
print(last_login == 0) # False — None is not 0
print(last_login == "") # False — None is not empty string either
Python also has a specific phrase just for checking None: is None. It answers the exact same kind of yes/no question as == — True or False — but it's the standard way to ask "is this specifically None?"
last_login = None
print(last_login is None) # True
x = None. Print it.
NonePrint None == 0, then None == "".
False then FalsePrint bool(None).
Falselast_login = None (a value that's deliberately empty — like a user who's never logged in). Print it directly.
None — no crash, it just prints None.Print last_login is None for a variable holding None.
Truelast_login = None. What does this do?
print(last_login + " days ago")TypeError: can only concatenate str (not "NoneType") to strYou can't glue text onto nothing. This is exactly the kind of bug real user data causes — you'll see it for real, with actual user records, once dict access is covered later.
Open problems/08_none.py and do all 8 problems locally.
You can convert between types on purpose — but not every conversion works.
print(int("5") + 1) # 6
print(str(5) + "!") # "5!"
Print int("5") + 1.
6Print str(5) + "!".
5!Print float("3.5") + 1.
4.5Print str(True), then str(None) on the next line.
True then Noneint("N/A") — what happens?
ValueError: invalid literal for int()Conversion only works if the text actually looks like that type.
Open problems/09_conversion.py and do all 8 problems locally.
An f-string drops variables straight into a text template — f"..." with {variable} inside.
email = "jrivera@example.com"
status = "ACTIVE"
print(f"{email} is {status}") # jrivera@example.com is ACTIVE
email, status. Print f"{email} is {status}".
jrivera@example.com is ACTIVEcount = 3. Print f"{count} users found".
3 users foundprice = 3.99. Print f"Price: {price}".
Price: 3.99light_on = True. Print f"Light on: {light_on}".
Light on: Truelast_login = None. Print f"Last login: {last_login}".
Last login: Nonecount = 3; print(f"{count} users found") — what prints?
"3 users found"f-strings convert non-string values automatically inside {}.
Open problems/10_fstrings.py — 10 problems, #10 is the final checkpoint for all of Part 1.
Run python check.py in problems/ to grade everything.