Skip to content

Commit 4b269a3

Browse files
committed
change baby names for life expectancy
1 parent 235557a commit 4b269a3

File tree

4 files changed

+54
-57
lines changed

4 files changed

+54
-57
lines changed

_layouts/default.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Exercises
2929
<ol>
3030
<li><a href="./basic">Basic exercises</a></li>
31-
<li><a href="./baby-names">Baby names</a></li>
31+
<li><a href="./mortality">Life expectancy tables</a></li>
3232
<li><a href="./copy-special">Copy special</a></li>
3333
<li><a href="./log-puzzle">Log puzzle</a></li>
3434
</ol>

basic.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ if you have not already (see the
99
[Set-Up](set-up) page for
1010
details).
1111

12-
**string1.py** -- complete the string functions in string1.py, based on
13-
the material in the [Python
14-
Strings](strings) section
15-
(additional exercises available in string2.py)
12+
In all of the following you can see how you are doing by running the file, e.g.
13+
`python3 string1.py` - the `manin` method will run some tests and print out if
14+
your code produces the right answer. Look for the string `# +++your code here+++`
15+
and replace it with your code, **save the file** and run it again to see if you
16+
are getting closer.
17+
18+
**string1.py** -- complete the string functions in string1.py, based
19+
on the material in the [Python Strings](strings) section (additional
20+
exercises available in string2.py)
1621

1722
**list1.py** -- complete the list functions in list1.py, based on the
1823
material in the [Python
@@ -36,4 +41,4 @@ the [Creative Commons Attribution 3.0
3641
License](http://creativecommons.org/licenses/by/3.0/), and code samples
3742
are licensed under the [Apache 2.0
3843
License](http://www.apache.org/licenses/LICENSE-2.0). For details, see
39-
our [Site Policies](https://developers.google.com/terms/site-policies).
44+
our [Site Policies](https://developers.google.com/terms/site-policies.

mortality.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Processing Life Expectancy Tables
2+
=================================
3+
4+
The Office for National Statistics (ONS) produces [life expectancy at birth
5+
tables](https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/lifeexpectancies)
6+
for various geographies for England and Wales. However, because they are
7+
statisticians they produce nasty broken Excel sheets instead of nice simple (and
8+
easy to use) CSV files.
9+
10+
In this exercise we will be taking a pair of raw data files
11+
(`counties-m-birth.csv` and `counties-f-birth.csv`) that have been saved out
12+
from Excel as CSV. They contain male and female life expectancies at birth for
13+
English counties. You will need to edit the file `life_expectancy.py` and add in
14+
some code to extract the lines we want (a header row and the ones with figures on),
15+
and then output them for each file.
16+
17+
If you finish that task then you can think on how you might add the ability to
18+
sort the rows based on a column the user specifies, or how you could combine the
19+
male and female figures to allow them to be compared more easily.

set-up.md

+24-51
Original file line numberDiff line numberDiff line change
@@ -34,70 +34,43 @@ Most operating systems other than Windows already have Python installed
3434
by default. To check that Python is installed, open a command line
3535
(typically by running the "Terminal" program), and cd to the
3636
google-python-exercises directory. Try the following to run the hello.py
37-
program (what you type is shown in bold):
37+
program (what you see here is what you type):
3838

39-
~/google-python-exercises$ python hello.py
40-
Hello World
41-
~/google-python-exercises$ python hello.py Alice
42-
Hello Alice
43-
44-
If python is not installed, see the [Python.org
45-
download](http://python.org/download) page. To run the Python
46-
interpreter interactively, just type "python" in the terminal:
39+
python3 hello.py
4740

48-
~/google-python-exercises$ python
49-
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
50-
[GCC 5.4.0 20160609] on linux2
51-
Type "help", "copyright", "credits" or "license" for more information.
52-
>>> 1 + 1
53-
2
54-
>>> you can type expressions here .. use ctrl-d to exit
41+
You will see:
5542

56-
For this course, you want a python version that is 2.7 or later.
43+
Hello World
5744

58-
### Execute Bit (optional)
45+
type:
5946

60-
The commands above are the simplest way to run python programs. If the
61-
"execute bit" is set on a .py file, it can be run by name without having
62-
to type "python" first. Set the execute bit with the "chmod" command
63-
like this:
47+
python3 hello.py Alice
6448

65-
~/google-python-exercises$ chmod +x hello.py
66-
~/google-python-exercises$ ./hello.py ## now can run it as ./hello.py
67-
Hello World
49+
see:
6850

69-
Python on Windows
70-
-----------------
51+
Hello Alice
7152

72-
Doing a basic Python install on Windows is easy:
53+
If python is not installed, see the [Python.org
54+
download](http://python.org/download) page. To run the Python
55+
interpreter interactively, just type "python3" (eventially everyone will switch
56+
over to Python3 and the command will become just "python") in the terminal:
7357

74-
- Go to the [python.org download](http://www.python.org/download/)
75-
page, select a version such as 2.7. Google's Python Class should
76-
work with any version 2.7.
77-
- Run the Python installer, taking all the defaults. This will install
78-
Python in the root directory and set up some file associations.
58+
python3
7959

80-
With Python installed, open a command prompt (Accessories &gt; Command
81-
Prompt, or type 'cmd' into the run dialog). Cd to the
82-
google-python-exercises directory (from unzipping
83-
google-python-exercises.zip). You should be able to run the hello.py
84-
python program by typing "python" followed by "hello.py" (what you type
85-
is shown in bold):
86-
C:\google-python-exercises> python hello.py
87-
Hello World
88-
C:\google-python-exercises> python hello.py Alice
89-
Hello Alice
60+
and you will see this header and can then type in your own commands and
61+
see the results:
9062

91-
If this works, Python is installed. Otherwise, see [Python Windows
92-
FAQ](http://www.python.org/doc/faq/windows/) for help.
63+
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
64+
[GCC 8.2.0] on linux
65+
Type "help", "copyright", "credits" or "license" for more information.
66+
>>> 1+1
67+
2
68+
>>>
9369

94-
To run the Python interpreter interactively, select the Run... command
95-
from the Start menu, and type "python" -- this will launch Python
96-
interactively in its own window. On Windows, use Ctrl-Z to exit (on all
97-
other operating systems it's Ctrl-D to exit).
70+
Type ctrl-z (on windows) or ctrl-d (on linux/macs) to exit.
9871

99-
Editing Python (all operating systems)
100-
--------------------------------------
72+
Editing Python
73+
--------------
10174

10275
A Python program is just a text file that you edit directly. As above,
10376
you should have a command line open, where you can type "python hello.py

0 commit comments

Comments
 (0)