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.

Exercise 1:

Let's define some variables. Fill in the gaps:

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]: ______

Exercise 2:

Let's change the content. Insert the correct values and variable names into the blanks.

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

If you like maths, you may sigh loud at the notion of redefining a variable every few lines.

Exercise 3:

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

Sarah
ASHLEY
madison alexis
sam90
2000jessy
liz_lauren
alyssa.kay

Exercise 4:

Which are correct variable assignments?

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

results matching ""

    No results matching ""