1. Concept library
  2. Python Foundations
  3. Module 1: Values, variables and types

Concept

Numbers and strings

The two kinds of value every program starts with: integers and floats for arithmetic, and strings for text. Knowing which one you hold decides what you can do with it.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain the difference between an int, a float and a string and give an example of each
  2. Predict the result of arithmetic that mixes ints and floats, including / and //
  3. Spot the TypeError in an expression that adds a string to a number and explain why Python raises it

In practice

A few lines that show Numbers and strings doing its job.

Python
price = 19.99          # float
quantity = 3           # int
label = "notebook"     # str

total = price * quantity
print(label, total)    # notebook 59.97
print(label * 2)       # notebooknotebook

The common mistake

Watch for

Mixing a number and a string in one expression. "3" + 4 raises a TypeError, because Python never guesses whether you meant 7 or "34".

How it stays learned

Once a session shows you understand Numbers and strings, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on Numbers and strings.