Additional material
Last updated on 2024-09-03 | Edit this page
A collection of facts about Python that do not fit into the main lesson either due to the scope or time constraints of the main lesson.
Jupyter Notebook/IPython: Who’s Who in Memory
You can use the %whos
command at any time to see what
variables you have created and what modules you have loaded into the
computer’s memory. As this is an IPython command, it will only work if
you are in an IPython terminal or the Jupyter Notebook.
OUTPUT
Variable Type Data/Info
--------------------------------
weight_kg float 100.0
weight_lb float 143.0
## Integer Division
We are using Python 3, where division always returns a floating point number:
OUTPUT
0.5555555555555556
Unfortunately, this wasn’t the case in Python 2:
OUTPUT
0
If you are using Python 2 and want to keep the fractional part of division you need to convert one or the other number to floating point:
OUTPUT
0.555555555556
OUTPUT
0.555555555556
OUTPUT
0.555555555556
OUTPUT
0.555555555556
And if you want an integer result from division in Python 3, use a double-slash:
OUTPUT
2
OUTPUT
1