1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
What is the name of the list that we're looping through here? | for a_clean_city in cleanest_cities: | cleanest_cities | ^ *cleanest_cities *$ |
What is the name of the variable that stores a list element each time through the loop? | for a_clean_city in cleanest_cities: | a_clean_city | ^ *a_clean_city *$ |
Looping through the list cleanest_cities, complete the line. | for a_clean_city ______________ | in cleanest_cities: | in `cleanest_cities`: |
We're looping through the list y and assigning each element to the variable x. Code the first line. | for x in y: | for x in y: | |
Looping through y, we're testing if x has the same value as z. Write the second line. Don't forget to indent the line. | for x in y: | if x == z: | ^ * if x == z: *$ |
Looping through y, we're testing if x has the same value as z. If so, display "ok". Write the third line. Don't forget to indent the line two tabs. | for x in y: if x == z: | print("ok") | ^ * print\(•ok•\) *$ |
Write the first line of a for loop. Make up the variable name and the list name. | for an_animal in animal_list: | ^ *for [a-zA-Z_][a-zA-Z0-9_]* in [a-zA-Z_][a-zA-Z0-9_]*: *$ | |
Write the first two lines of a for loop. The second line tests whether the list element is greater than or equal to 99. Make everything else up. Don't forget to indent the second line. | for x in y: if x >= 99: | ^ *for ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*:\n if \1 >= 99: *$ | |
Loop through a list, displaying each element. Make up the names. | for x in y: print(x) | ^ *for ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*:\n print\(\1\) *$ | |
Loop through a list. If the element has the same value as some variable, display "ok". Make everything up. | for x in y: if x == z: print("ok") | ^ *for ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*:\n if \1 == [a-zA-Z_][a-zA-Z0-9_]*:\n print\(•ok•\) *$ | |
| e730f3426b | ||
| b562f1521d |