0
0
Testing Fundamentalstesting~10 mins

Identifying performance bottlenecks in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start measuring the time before the function runs.

Testing Fundamentals
start_time = [1]()
Drag options to blanks, or click blank then click option'
Alen
Bprint
Ctime.time
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using print() instead of time.time()
Using len() which counts length, not time
2fill in blank
medium

Complete the code to calculate the elapsed time after the function runs.

Testing Fundamentals
elapsed = [1]() - start_time
Drag options to blanks, or click blank then click option'
Aprint
Btime.time
Clen
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using print() instead of time.time()
Not subtracting start_time
3fill in blank
hard

Fix the error in the code to correctly measure the time taken by the function call.

Testing Fundamentals
def test_function():
    [1]('Starting test')
    # function code here
    print('Test done')
Drag options to blanks, or click blank then click option'
Aprint
Binput
Ctime.time
Dtime.sleep
Attempts:
3 left
💡 Hint
Common Mistakes
Using time.time() as a function call without parentheses
Using time.sleep() which pauses execution
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.

Testing Fundamentals
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Dword.length
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.length which is not valid in Python
Using word instead of len(word) for the value
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if length is greater than 4.

Testing Fundamentals
{ [1]: [2] for word in words if [3] > 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of word.upper() for the key
Using word.length which is invalid in Python