44.1k views
1 vote
1|>[fill in this blank]

2|>>if is_weekend and time > 9:
3|>>>return True
4|>>elif not is_weekend and time > 6:
5|>>>return True
6|>>else:
7|>>>return False
8|
9|>wake_up(5)
10|>wake_up(8, is_weekend = True)
Q: The code above attempts to define and then call a function called wake_up. wake_up returns True if the time given by the positional parameter time is after 9 on a weekend or 6 on a weekday, False if it does not. By default, wake_up assumes is_weekend is False.
Which of the following code segments could we insert in the blank to complete this function?

User Bryan Chen
by
8.5k points

1 Answer

6 votes

Final answer:

The code segment that can be inserted in the function is 'return time > 9'.

Step-by-step explanation:

In the blank, we can insert the code segment:

return time > 9

This code checks if the given time is greater than 9 and returns True if it is. Since the default value of is_weekend is False, we don't need to explicitly check it in the code. This code segment completes the wake_up function by returning True if the time is after 9 on any day, and False otherwise.

User Androliyah
by
7.4k points