Oliver Irwin
10th March 2023
Programmers aim to be lazy and to write as little code as possible to solve a task
Writing the same code twice = no-no
For that, we use the machine’s memory and variables
a variable is a box in the machine’s memory where we can store a value
we can then reuse the value at multiple different places in the code
to create a variable, you declare it
in Python, this is done with the =
sign
creates a variable named a
which contains the value 42
variable names follow rules
_
a variable can be used unlimited number of times
you can access it’s value by using the identifier (the name)
as we have seen earlier, variables can be of different types
a type is a family of values
each type allows different operations to be done
most common type groups: numbers, text
two main types of numbers:
1
, 153
, -254
)1.2
, 3.1415
)classical operations
3 types of division possible:
text is represented by strings
to create a string, put text in quotes ("
)
we can concatenate strings