<aside> 💡 All assignments are marked by Python 3.10.5

</aside>

Types and Data Structures

Variables, Objects and Types

Terminology

A type defines possible values & operations (for objects).

An object is a value in memory referenced by an identifier.

A value is a set of bits interpreted according to a type.

A variable is a named object.

A literal is a notation for representing a fixed value in source code.

Types

Type Description Comments
NoneType Defines null objects and variables None
bool Boolean values True or False
int Integer unbounded integer
float Floating point numbers 64-bit floating point
complex Complex numbers complex number
str Strings sequence of characters
list Lists
dict Dictionaries
tuple Tuples
Object Type Description
Files Files created using the open() function
Program unit types Functions, modules, classes
Implementation-related types Compiled code, stack tracebacks

Use type() to know an object’s type.

Immutable vs. Mutable

Immutable: an object whose state cannot be modified after it is created

Mutable: an object whose state can be modified after it is created