Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 1.28 KB

variables_and_numbers.md

File metadata and controls

66 lines (43 loc) · 1.28 KB

Storing numbers

The U.S. authorities record the names of all babies born since 1880. How many babies with more or less popular names were born in 2000? Let's store the numbers in variables.

Warming up

Let's define some variables:

In [1]: emily = 25952
In [2]: hannah = 23073
In [3]: khaleesi = 5
In [4]: emily
Out[4]: ______
In [5]: hannah + 1
Out[5]: ______
In [6]: 3 * khaleesi
Out[6]: ______

Let's change the content:

In [7]: emily = emily + 1
In [8]: emily
Out[8]: _____

In [9]: all_babies = 0
In [10]: all_babies = _____ + _____ + _____
In [11]: all_babies
Out[11]: 49031

Insert the correct values and variable names into the blanks.

Exercises

Complete the following exercises:

Exercise 1:

Which of the following variable names are correct? Try assigning some numbers to them.

Emily
EMILY
emily brown 
emily25
25emily
emily_brown
emily.brown

Exercise 2:

Which are correct variable assignments?

  • a = 1 * 2
  • 2 = 1 + 1
  • 5 + 6 = y
  • seven = 3 * 4

The Challenge: Calculate an average

What is the average number of the top five boy names?

Calculate the number and store it in a variable.

Make a very rough estimate before you do the calculation.