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
If a condition isn't True, it's _______. | False | ^ *False *$ | |
Rewrite this Boolean assignment so it's valid. | the_flag = "False" | the_flag = False | ^ *the_flag = False *$ |
Rewrite this statement using a Boolean instead of the string. | while incomplete == "yes": | while incomplete == True: | while `incomplete `=`= `True`: |
Code the first line of an if statement that tests the falsity of today_is_tuesday . | if today_is_tuesday == False: | if today_is_tuesday == False: | |
Assign one of the Booleans to a variable. Make everything up. | job_complete = True | ^ *[a-zA-Z_][a-zA-Z0-9_]* = True|False *$ | |
If one variable is True, a second variable is False. Write the code. Make up the variable names. | if x == True: y = False |
^ *if [a-zA-Z_][a-zA-Z0-9_]* == True:\n [a-zA-Z_][a-zA-Z0-9_]* = False *$ | |
If a variable is False, change it to True. Make up the name of the variable. | if x == False: x = True |
^ *if ([a-zA-Z_][a-zA-Z0-9_]*) == False:\n \1 = True *$ | |
Code a for loop that loops through a list. When an element in the list is False, break the loop. Make up the name of the list and the variable. | for an_element in list_of_booleans: if an_element == False: break |
^ *for ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*:\n if \1 == False:\n break *$ | |
Assign True to a variable. If another variable is True, change the Boolean of the first variable. Make everything up. | first_var = True if second_var == True: first_var = False |
^ *([a-zA-Z_][a-zA-Z0-9_]*) = True\nif [a-zA-Z_][a-zA-Z0-9_]* == True:\n \1 = False *$ | |
If the sum of two variables equals a third variable and a fourth variable is False, change the fourth variable. Otherwise, add the first variable to itself using concise coding. Make everything up. | if a + b == c and d == False: d = True else: a += a |
^ *if ([a-zA-Z_][a-zA-Z0-9_]*) \+ [a-zA-Z_][a-zA-Z0-9_]* == [a-zA-Z_][a-zA-Z0-9_]* and ([a-zA-Z_][a-zA-Z0-9_]*) == False:\n \2 = True\nelse:\n \1 \+= \1 *$ | |
|
745350f57c | ||
|
81da750f3d |