Additional Material

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.

These are instructor extensions. Learner-facing practice and official documentation are collected separately in Learner Additional Material. Use the Instructor Notes to decide which extension suits the cohort.

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.

%whos
Variable    Type       Data/Info
--------------------------------
weight_kg   float      100.0
weight_lb   float      143.0


## Integer Division

The following Python 2 examples are historical context, not a supported course environment or code learners should run. Applied Python uses Python 3. For current practice, compare / with // and ask learners to predict both results.

We are using Python 3, where division always returns a floating point number:

5/9
0.5555555555555556

Unfortunately, this wasn’t the case in Python 2:

5/9
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:

float(5)/9
0.555555555556
5/float(9)
0.555555555556
5.0/9
0.555555555556
5/9.0
0.555555555556

And if you want an integer result from division in Python 3, use a double-slash:

4//2
2
3//2
1

Course Navigation

Course Overview · Instructor Notes · Additional Material · Extra Exercises · Learner Setup