Complete the code to start measuring the time before the function runs.
start_time = [1]()We use time.time() to get the current time in seconds before running the code to measure elapsed time.
Complete the code to calculate the elapsed time after the function runs.
elapsed = [1]() - start_timeWe call time.time() again to get the current time after the function finishes, then subtract the start time to get elapsed time.
Fix the error in the code to correctly measure the time taken by the function call.
def test_function(): [1]('Starting test') # function code here print('Test done')
The code intends to print a message. Using print is correct here. Using time.time or time.sleep would cause errors or wrong behavior.
Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.
{word: [1] for word in words if [2] > 3}word.length which is not valid in Pythonword instead of len(word) for the valueThe dictionary comprehension maps each word to its length using len(word). The condition checks if len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if length is greater than 4.
{ [1]: [2] for word in words if [3] > 4 }word instead of word.upper() for the keyword.length which is invalid in PythonThe comprehension maps the uppercase version of each word to its length. The condition checks if the length is greater than 4.