Part One
Data Type Map
Every value in Python has a type. A type tells Python what that value is and what you can do with it. The most important groups are:
Numeric: int, float (and complex, which we will skip for now)
Boolean: True, False
String: text values like "hello"
Collections: list, tuple, set, dict
Part Two
Numeric Types
Python also has complex numbers, but we will not be dealing with complex numbers in this course.
int — whole numbers
Integers have no decimal point. Use them for counting and indexing.
float — decimal numbers
Floats store values with decimals.
Part Three
Strings, Booleans, and None
str — text
Strings are text values inside quotes. You can combine and slice them.
bool — True or False
Booleans represent logical answers: yes/no, pass/fail, on/off.
NoneType — no value yet
None is used when a variable has no meaningful value yet.
Part Four
Collection Types
Collection types hold multiple values, but each one behaves differently.
list — ordered and changeable
A list keeps items in order, allows duplicates, and can be modified after creation. Use a list when order matters and you expect to add, remove, or update items.
You access list items by index: 0 is the first item, 1 is the second, and so on.
tuple — ordered and fixed
A tuple is like a list that cannot be changed after creation. It keeps order, allows duplicates, and supports indexing.
Use tuples for values that should stay constant, such as coordinates, RGB colors, or fixed settings.
set — unique values, no order
A set stores unique values only. If you add the same value more than once, it appears only once.
Sets are useful for removing duplicates and for fast membership checks like if "python" in tags.
Common methods: .add(value) to insert, .remove(value) to delete (error if missing), .discard(value) to delete safely (no error if missing), and .pop() to remove and return one arbitrary item.
dict — key/value pairs
A dictionary stores data as key: value pairs. You use a key (label) to access its value.
Use dictionaries when each value has a meaningful name, such as student attributes, settings, or lookup tables.
Common methods: .get(key) for safe reading, .keys() and .values() to inspect data, .items() to loop key/value pairs, .update({...}) to add new key/value pairs or change existing ones, and .pop(key) to remove one key and return its value.
list is ordered and editable, tuple is ordered and fixed, set keeps only unique values, and dict stores labeled data with keys.
Chapter Navigation
Move between chapters.