Lecture 2 – Jupyter Notebooks and Arithmetic¶

Data 6, Summer 2021¶

In each of the following cells, there is an expression. After running each cell, you see the value of that expression.

In general, Jupyter notebook cells show you the value of the very last expression in a cell. But generally we'll want to do more than one computation in a cell. In the next lecture, we'll learn how to store our calculations in variables. But for now...

This is a Markdown cell! You can change the type of a cell by going to the cell toolbar.

Here's an example of a useless comment.

Here's an example of a better comment.

Variable Types¶

We glossed over something earlier – it seems like there are two different types of numbers!

You can get the type of a value by calling the type function. We will learn more about functions later.

Any time you add, subtract, or multiply any number of ints, the result is still an int. But anytime you divide, or use a float in a calculation, the result is a float.

Weird things can happen when performing arithmetic with floats.

Errors¶

What happens if we try dividing by 0?

You'll also get an error if your code is syntactically wrong.