17.9 Chapter Assessment
From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython2 class periods9 exercises20 graded tests
17.9 Chapter Assessment
Exercise 1
The variable nested contains a nested list. Assign 'snake' to the variable output using indexing.
Open the
01folder and editmain.py. Run Tests checks it.
Exercise 2
Below, a list of lists is provided. Use in and not in tests to create variables with Boolean values. See comments for further instructions.
Open the
02folder and editmain.py. Run Tests checks it.
Exercise 3
Below, we've provided a list of lists. Use in statements to create variables with Boolean values - see the ActiveCode window for further directions.
Open the
03folder and editmain.py. Run Tests checks it.
Exercise 4
Provided is a nested data structure. Follow the instructions in the comments below. Do not hard code.
Open the
04folder and editmain.py. Run Tests checks it.
Exercise 5
The variable nested_d contains a nested dictionary with the gold medal counts for the top four countries in the past three Olympics. Assign the value of Great Britain's gold medal count from the London Olympics to the variable london_gold. Use indexing. Do not hardcode.
Open the
05folder and editmain.py. Run Tests checks it.
Exercise 6
Below, we have provided a nested dictionary. Index into the dictionary to create variables that we have listed in the ActiveCode window.
Open the
06folder and editmain.py. Run Tests checks it.
Exercise 7
Given the dictionary, nested_d, save the medal count for the USA from all three Olympics in the dictionary to the list US_count.
Open the
07folder and editmain.py. Run Tests checks it.
Exercise 8
Iterate through the contents of l_of_l and assign the third element of sublist to a new list called third.
Open the
08folder and editmain.py. Run Tests checks it.
Exercise 9
Given below is a list of lists of athletes. Create a list, t, that saves only the athlete's name if it contains the letter "t". If it does not contain the letter "t", save the athlete name into list other.
Open the
09folder and editmain.py. Run Tests checks it.
For teachers
17.9 Chapter Assessment
Students read Foundations of Python Programming's “Chapter Assessment” in CS Room and work through its 9 Python coding exercises (9 graded).
- Time: 2 class periods
- Tests: 20 in 9 graded exercises, set up for you when you import the lesson
Exercises
| Folder | Grading | Tests |
|---|---|---|
01 | Autograded | 1 |
02 | Autograded | 3 |
03 | Autograded | 3 |
04 | Autograded | 4 |
05 | Autograded | 1 |
06 | Autograded | 4 |
07 | Autograded | 1 |
08 | Autograded | 1 |
09 | Autograded | 2 |