A student writes the short Python program below to test a function that raises a number to a power. What does the program print when it runs?
def power(base, exponent): return base ** exponent exponent = 3 base = 2 print(power(exponent, base + 2))
It prints 9.
It prints 64.
It prints 81.
It prints 8.
Unlock full course notes by signing up
Valid calls with keyword and default arguments
A hotel booking program defines the Python function below. Which of the following calls run without raising an error? Select all that apply.
Follow box counts through helper calls
A delivery program combines two orders and removes rejected boxes before recording a van's load. Consider this Python code:
Determine the value received by packed in prepare_load and the value received by boxes in log_load. Give both quantities in boxes, as exact integers with zero decimal places.
Reassigning versus mutating a parameter
Consider the Python program below, which adds a bonus entry to a list of quiz marks. What number does the final line print? Give your answer as a whole number.
Track a list used as a default argument
A route-planning prototype uses this Python function. The method append adds one entry to a list, and len gives the number of entries in that list.
The function definition executes once, followed by these five calls in order, with no other calls or changes. For each call, enter the printed count and the number of entries in the list stored as the default value for route after that call. Track that default list even when a call explicitly supplies another list. Enter exact integers.