Toggle Questions¶
Put the blocks in order to define the function has22
to return True
if there are at least two items in the list nums that are adjacent and both equal to 2, otherwise return False
. For example, return True
for has22([1, 2, 2])
since there are two adjacent items equal to 2 (at index 1 and 2) and False
for has22([2, 1, 2])
since the 2’s are not adjacent.
Finish the function has22
below to return True
if there are at least two items in the list nums
that are adjacent and both equal to 2, otherwise return False
. For example, return True
for has22([1, 2, 2])
since there are two adjacent items equal to 2 (at index 1 and 2) and False
for has22([2, 1, 2])
since the 2’s are not adjacent.
- Nothing is printed. A runtime error occurs.
- It is legal to change the type of data that a variable holds in Python.
- Thursday
- This is the first value assigned to the variable day, but the next statements reassign that variable to new values.
- 32.5
- This is the second value assigned to the variable day, but the next statement reassigns that variable to a new value.
- 19
- The variable day will contain the last value assigned to it when it is printed.
What is printed when the following statements execute?
day = "Thursday"
day = 32.5
day = 19
print(day)
- True
- - The + character is not allowed in variable names.
- False
- - The + character is not allowed in variable names (everything else in this name is fine).
True or False: the following is a legal variable name in Python: A_good_grade_is_A+