Skip to content

Latest commit

 

History

History
77 lines (46 loc) · 1.22 KB

python_shell.md

File metadata and controls

77 lines (46 loc) · 1.22 KB

Using Python as a calculator

Warming up

Enter Python in the interactive mode. You should see a message

In [1]:

Complete the following calculations by filling in the blanks:

In [1]: 1 + ___
Out[1]: 3

In [2]: 12 ___ 8
Out[2]: 4

In [3]: ___ * 5
Out[3]: 20

In [4]: 21 / 7
Out[4]: ___

In [5]: ___ ** 2
Out[5]: 81

Enter the commands to see what happens (do not type the first part In [1] etc., these will appear automatically).

Exercises

Complete the following exercises:

Exercise 1:

There are more operators in Python. Find out what the following operators do?

3 ** 3
24 % 5
23 // 10

Exercise 2:

Which of the following Python statements are valid? Try them in the IPython shell.

0 + 1
2 3
4-5
6 * * 7
8 /
9

Exercise 3:

Which operations result in 8?

  • 65 // 8
  • 17 % 9
  • 2 ** 4
  • 64 ** 0.5

The Challenge: Boys' names total

In the table, you find the five most popular boys' names from the year 2000. What is the total number of boys in the top5?

name number
Jacob 34465
Michael 32025
Matthew 28569
Joshua 27531
Christopher 24928