Slides 02 Python
Slides 02 Python
Arithmetic Readings
Variables Python
Conclusion
Michael Burrell
Readings
Python
4 + (2 ** 2 + 7) / 2
Expressions in Python follow the usual algebraic order of
operations
4 + (2 ** 2 + 7) / 2
Expressions in Python follow the usual algebraic order of
operations
int vs float
int vs float
Type conversions
Soon we’ll look at doing this ourselves, but first we’ll look
at implicit type conversions (type promotions)
Type conversions
1
This is only true in Python 3, not Python 1 or Python 2
Michael Burrell Expressions, types, variables
Introduction
Arithmetic
Types
Variables
Conclusion
Type conversions
Variables
Variables
x=3
To introduce a new variable, you name it and put it on
the left of the = sign
Variables
x = 3
y = x * 2
x = x - 1
print(x + y) – what’s the answer here?
Strings
So far we know of 2 types in Python
Strings
So far we know of 2 types in Python
Operations on strings
Booleans
The last type we’ll look at today is the booleans (bool in
Python)
Conclusion