Code

Kinds of Values

Every value in Python has a type, what kind of thing it is. You've met some already:

Type What it is Examples
str text (a string) "Pip", "42"
int whole number (integer) 7, -3, 0
float number with a decimal point 2.5, 10.0
bool yes/no (boolean) True, False
NoneType "nothing here yet" None

True, False and None start with a capital letter and have no quotes.

Ask Python for a value's type with type():

print(type(7))       # <class 'int'>
print(type("7"))     # <class 'str'>  quotes make it text!
print(type(7.0))     # <class 'float'>
print(type(False))   # <class 'bool'>

None is useful when something doesn't exist yet, like a lighthouse that has no keeper assigned.

Assignment

Fill in the lighthouse's record card:

  1. name: the text "Moonwell"
  2. floors: the whole number 4
  3. height: the decimal number 12.5
  4. is_lit: False (it's dark right now)
  5. keeper: None (no keeper yet)