0
0
Testing Fundamentalstesting~10 mins

Why testing prevents costly failures in Testing Fundamentals - Test Your Understanding

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

Complete the code to print a message when a test fails.

Testing Fundamentals
if test_result == [1]:
    print("Test failed! Please fix the bug.")
Drag options to blanks, or click blank then click option'
A"passed"
B"fail"
C"success"
D"ok"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "passed" or "success" will never trigger the failure message.
2fill in blank
medium

Complete the code to check if a bug is costly before reporting.

Testing Fundamentals
if bug_severity [1] 5:
    report_bug()
Drag options to blanks, or click blank then click option'
A<
B==
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will report less severe bugs, which is not the goal.
3fill in blank
hard

Fix the error in the assertion to check if the function output is correct.

Testing Fundamentals
assert [1] == expected_output, "Output mismatch!"
Drag options to blanks, or click blank then click option'
Aresult
Binput
Cprint
Dlen
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'input' or 'print' causes errors or wrong checks.
4fill in blank
hard

Fill both blanks to create a test that checks if a number is positive and less than 100.

Testing Fundamentals
if number [1] 0 and number [2] 100:
    print("Valid number")
Drag options to blanks, or click blank then click option'
A>
B<=
C<
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' or '<=' changes the range and may include invalid numbers.
5fill in blank
hard

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

Testing Fundamentals
lengths = { [1]: [2] for [1] in words if len([1]) [3] 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will select short words, which is incorrect.