10a: in-class assignment 4
Table of Contents
1. Planning
- Prep: 09:00-09:40 (40 mins)
- Break: 09:40-09:55 (15 mins)
- Regular time: 09:55 - 10:35 (40 mins)
- Extra time: 09:55 - 10:45 (50 mins)
2. Prep
Take a look at this dictionary:
populations = {"France" : 68000000, "Netherlands": 18000000, "Belgium" : 11700000, "Germany" : 83000000}
Use Python to create a .txt file with on every line one key-value pair, like this:
France,68000000 Netherlands,18000000 Belgium,11700000 Germany,83000000
Then write a function that takes the path to this .txt file as input, and outputs a list that contains four sublists, with each sublist consisting of the country and its population. Like this:
[["France",68000000],["Netherlands",18000000],["Belgium",11700000],["Germany",83000000]]
3. Extra prep
- How many times does the character "e" occur in the names of all countries together?
- How many people live in all countries? Together?
4. Remember
- split
- strip