← Course Home
Part 1

Core Values

Variables and types — the stuff every script is built on top of.

Before we start

Showing Something on Screen

print() shows something on the screen. Write the word print, then parentheses, then whatever you want shown, inside them.

print("Hello")
Lab 1

Print the word Hello.

print("Hello")Hello
Lab 2

Print your name as text, e.g. "Sam".

print("Sam")Sam
Before we start

Text vs. Numbers

Text (words, sentences, an email) needs quotes around it. Numbers don't.

print("Hello")   # text — quotes
print(10)        # number — no quotes
Lab 3

Print the number 10 (no quotes — it's a number).

print(10)10
Lab 4

Print the number 3.99 (a decimal, still no quotes).

print(3.99)3.99
Concept

Making a Variable

A 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)
Lab 1

You have 10 apples. Store that in a variable called apples, then print it.

apples = 10
print(apples)
10
Lab 2

Store a user's email, "jrivera@example.com", in email, then print it.

email = "jrivera@example.com"
print(email)
Lab 3

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.
Lab 4

Store the text "IT" in department, then print it.

department = "IT"
print(department)
Lab 5

Store whether a light is on (True) in light_on, then print it.

light_on = True
print(light_on)
Predict first

What if you print a name nobody ever put in a jar? print(Sam) — no quotes. What happens?

Check
Crashes: NameError: name 'Sam' is not defined

No jar labeled Sam exists — nobody wrote Sam = ... anywhere. Python looked, found nothing, and stopped instead of guessing.

Now go practice

Open problems/01_create.py and do all 5 problems locally before moving on.

Concept

Giving It a New Value

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
Lab 1

apples = 10, then you eat 3. Reassign to 7. Print old, then new.

apples = 10
print(apples)
apples = 7
print(apples)
10 then 7
Lab 2

price = 3.99, on sale for 2.99. Reassign, print old then new.

3.99 then 2.99
Lab 3

status = "ACTIVE", account gets suspended. Reassign to "SUSPENDED", print both.

ACTIVE then SUSPENDED
Lab 4

light_on = True, then turned off. Reassign to False, print both.

True then False
Lab 5

count = 1, reassign twice in a row (to 2, then 3). Print only the final value.

3
Now go practice

Open problems/02_reassign.py and do all 5 problems locally.

Concept

What Type Is It?

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.

Lab 1

Print the type of apples (10).

<class 'int'>
Lab 2

Print the type of email ("jrivera@example.com").

<class 'str'>
Lab 3

Print the type of price (3.99).

<class 'float'>
Lab 4

Print the type of light_on (True).

<class 'bool'>
Predict first

print(type(10 / 2)) — division always returns a decimal type, even if the answer is whole.

Check
<class 'float'>
Now go practice

Open problems/03_type_check.py and do all 5 problems locally.

Concept

Strings

A string is text. Glue two strings together with +.

Example
user_id = "00u001"
print(user_id + "!")   # "00u001!"
print(len(user_id))    # 6 — len() counts the characters
Lab 1

first = "Julio", last = "Rivera". Combine into "Julio Rivera" using + (don't forget the space).

first + " " + last
Lab 2

Print first + last (no space), then first + " " + last (with space).

JulioRivera then Julio Rivera
Lab 3

Print a string, then print its len() on the next line.

e.g. jrivera@example.com19
Lab 4

" 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.
Lab 5

Print "IT" + "-" + "001" as one combined string.

IT-001
Now go practice

Open problems/04_string.py and do all 6 problems locally.

Concept

Whole Numbers

No quotes, no decimal point. Used for counts — not for things like IDs, even when an ID looks numeric.

Lab 1

apples = 10. Print it.

10
Lab 2

You buy 5 more apples. Print apples + 5.

15
Lab 3

You eat 4 apples. Print apples - 4.

6
Predict first

10 apples split into groups of 3. print(10 // 3) — how many full groups?

Check
3
Predict first

Same split — print(10 % 3) — how many left over?

Check
1
Now go practice

Open problems/05_integer.py — 6 problems, #6 is a checkpoint combining sub-skills 1–5.

Concept

Decimals

Numbers with a decimal point. Mixing a whole number and a decimal (3 + 0.5) produces a decimal result — the more precise type wins.

Lab 1

price = 3.99. Print it.

3.99
Lab 2

Print 3 + 0.5, then type(3 + 0.5) on the next line.

3.5 then <class 'float'>
Lab 3

Print 10 / 4 — dividing two whole numbers still gives a decimal.

2.5
Lab 4

Print round(3.14159, 1).

3.1
Lab 5

Like a two-line receipt: print price, then print the text Coffee on the next line (two separate prints).

3.99 then Coffee
Now go practice

Open problems/06_float.py and do all 6 problems locally.

Concept

True or False

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.

Example
is_active = True
print(bool(""))    # False — empty text
print(bool("hi"))  # True — non-empty text
print(bool(0))     # False — zero
Lab 1

light_on = True. Print it, then print type(light_on).

True then <class 'bool'>
Lab 2

Print bool(""), then bool("x").

False then True
Lab 3

Print bool(0), then bool(1).

False then True
Lab 4

Print bool([]), then bool(["Engineering"]).

False then True
Predict first

print(bool(None))

Check
False
Now go practice

Open problems/07_boolean.py and do all 7 problems locally.

Concept

Nothing At All

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.

Example
last_login = None
print(last_login == 0)      # False — None is not 0
print(last_login == "")     # False — None is not empty string either
Concept

A Special Way to Check for None

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
Lab 1

x = None. Print it.

None
Lab 2

Print None == 0, then None == "".

False then False
Lab 3

Print bool(None).

False
Lab 4

last_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.
Lab 5

Print last_login is None for a variable holding None.

True
Predict first

last_login = None. What does this do?

print(last_login + " days ago")
Check
CrashesTypeError: can only concatenate str (not "NoneType") to str

You 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.

Now go practice

Open problems/08_none.py and do all 8 problems locally.

Concept

Converting Between Types

You can convert between types on purpose — but not every conversion works.

Example
print(int("5") + 1)   # 6
print(str(5) + "!")   # "5!"
Lab 1

Print int("5") + 1.

6
Lab 2

Print str(5) + "!".

5!
Lab 3

Print float("3.5") + 1.

4.5
Lab 4

Print str(True), then str(None) on the next line.

True then None
Predict first

int("N/A") — what happens?

Check
CrashesValueError: invalid literal for int()

Conversion only works if the text actually looks like that type.

Now go practice

Open problems/09_conversion.py and do all 8 problems locally.

Concept

Printing It All Together

An f-string drops variables straight into a text template — f"..." with {variable} inside.

Example
email = "jrivera@example.com"
status = "ACTIVE"
print(f"{email} is {status}")   # jrivera@example.com is ACTIVE
Lab 1

email, status. Print f"{email} is {status}".

jrivera@example.com is ACTIVE
Lab 2

count = 3. Print f"{count} users found".

3 users found
Lab 3

price = 3.99. Print f"Price: {price}".

Price: 3.99
Lab 4

light_on = True. Print f"Light on: {light_on}".

Light on: True
Lab 5

last_login = None. Print f"Last login: {last_login}".

Last login: None
Predict first

count = 3; print(f"{count} users found") — what prints?

Check
"3 users found"

f-strings convert non-string values automatically inside {}.

Now go practice

Open problems/10_fstrings.py — 10 problems, #10 is the final checkpoint for all of Part 1.

Complete

Part 1 done

variable → reassign → type() → string → integer → float → boolean → None → conversion → f-strings.

Run python check.py in problems/ to grade everything.