9.18 Chapter Assessment - List Methods
From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython3 class periods14 exercises14 graded tests
9.18 Chapter Assessment - List Methods
Check your understanding
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Exercise 1
Write code to add 'horseback riding' to the third position (i.e., right before volleyball) in the list sports.
Open the
01folder and editmain.py. Run Tests checks it.
Exercise 2
Write code to take 'London' out of the list trav_dest.
Open the
02folder and editmain.py. Run Tests checks it.
Exercise 3
Write code to add 'Guadalajara' to the end of the list trav_dest using a list method.
Open the
03folder and editmain.py. Run Tests checks it.
Chapter Assessment - Aliases and References
Check your understanding
Check your understanding: a fill-in-the-blank question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Chapter Assessment - Split and Join
Check your understanding: a multiple-choice question in the book.
Exercise 4
Write code to find the position of the string "Tony" in the list awards and save that information in the variable pos.
Open the
04folder and editmain.py. Run Tests checks it.
Chapter Assessment - For Loop Mechanics
Check your understanding
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a fill-in-the-blank question in the book.
Exercise 5
Currently there is a string called str1. Write code to create a list called chars which should contain the characters from str1. Each character in str1 should be its own element in the list chars.
Open the
05folder and editmain.py. Run Tests checks it.
Chapter Assessment - Accumulator Pattern
Check your understanding
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Check your understanding: a multiple-choice question in the book.
Exercise 6
For each character in the string saved in ael, append that character to a list that should be saved in a variable app.
Open the
06folder and editmain.py. Run Tests checks it.
Exercise 7
For each string in wrds, add 'ed' to the end of the word (to make the word past tense). Save these past tense words to a list called past_wrds.
Open the
07folder and editmain.py. Run Tests checks it.
Exercise 8
Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list. (You should use the len function).
Open the
08folder and editmain.py. Run Tests checks it.
Exercise 9
Create an empty string and assign it to the variable lett. Then using range, write code such that when your code is run, lett has 7 b's ("bbbbbbb").
Open the
09folder and editmain.py. Run Tests checks it.
Exercise 10
Below are a set of scores that students have received in the past semester. Write code to determine how many are 90 or above and assign that result to the value a_scores.
Open the
10folder and editmain.py. Run Tests checks it.
Exercise 11
Write code that uses the string stored in org and creates an acronym which is assigned to the variable acro. Only the first letter of each word should be used, each letter in the acronym should be a capital letter, and there should be nothing to separate the letters of the acronym. Words that should not be included in the acronym are stored in the list stopwords. For example, if org was assigned the string "hello to world" then the resulting acronym should be "HW".
Open the
11folder and editmain.py. Run Tests checks it.
Exercise 12
Write code that uses the string stored in sent and creates an acronym which is assigned to the variable acro. The first two letters of each word should be used, each letter in the acronym should be a capital letter, and each element of the acronym should be separated by a ". " (dot and space). Words that should not be included in the acronym are stored in the list stopwords. For example, if sent was assigned the string "height and ewok wonder" then the resulting acronym should be "HE. EW. WO".
Open the
12folder and editmain.py. Run Tests checks it.
Exercise 13
A palindrome is a phrase that, if reversed, would read the exact same. Write code that checks if p_phrase is a palindrome by reversing it and then checking if the reversed version is equal to the original. Assign the reversed version of p_phrase to the variable r_phrase so that we can check your work.
Open the
13folder and editmain.py. Run Tests checks it.
Exercise 14
Provided is a list of data about a store's inventory where each item in the list represents the name of an item, how much is in stock, and how much it costs. Print out each item in the list with the same formatting, using the .format method (not string concatenation). For example, the first print statment should read The store has 12 shoes, each for 29.99 USD.
Open the
14folder and editmain.py. Run Tests checks it.
For teachers
9.18 Chapter Assessment - List Methods
Students read Foundations of Python Programming's “Chapter Assessment - List Methods” in CS Room and work through its 14 Python coding exercises (14 graded).
- Time: 3 class periods
- Tests: 14 in 14 graded exercises, set up for you when you import the lesson
Exercises
| Folder | Grading | Tests |
|---|---|---|
01 | Autograded | 1 |
02 | Autograded | 1 |
03 | Autograded | 1 |
04 | Autograded | 1 |
05 | Autograded | 1 |
06 | Autograded | 1 |
07 | Autograded | 1 |
08 | Autograded | 1 |
09 | Autograded | 1 |
10 | Autograded | 1 |
11 | Autograded | 1 |
12 | Autograded | 1 |
13 | Autograded | 1 |
14 | Autograded | 1 |