0
0
Testing Fundamentalstesting~10 mins

Statement coverage 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 calculate statement coverage percentage.

Testing Fundamentals
coverage = (executed_statements / [1]) * 100
Drag options to blanks, or click blank then click option'
Aexecuted_statements
Btotal_statements
Ctotal_tests
Dfailed_statements
Attempts:
3 left
💡 Hint
Common Mistakes
Using executed_statements as denominator instead of total_statements
Using total_tests which is unrelated to statement count
2fill in blank
medium

Complete the code to check if all statements were executed.

Testing Fundamentals
if executed_statements [1] total_statements:
    print("All statements covered")
Drag options to blanks, or click blank then click option'
A<
B!=
C>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '>' which do not confirm full coverage
Using '!=' which checks for inequality
3fill in blank
hard

Fix the error in the code to correctly calculate coverage as a float.

Testing Fundamentals
coverage = executed_statements / [1]
Drag options to blanks, or click blank then click option'
Afloat(total_statements)
Bstr(total_statements)
Cint(total_statements)
Dtotal_statements
Attempts:
3 left
💡 Hint
Common Mistakes
Using int conversion which does not change type
Using str conversion which causes errors
4fill in blank
hard

Fill both blanks to create a dictionary of statement coverage for multiple modules.

Testing Fundamentals
coverage_dict = {module: executed[1] / total[2] for module, executed_statements, total_statements in data}
Drag options to blanks, or click blank then click option'
A_statements
B_tests
D_cases
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent suffixes like _tests or _cases
Mixing different suffixes for executed and total
5fill in blank
hard

Fill all three blanks to filter modules with coverage above 80%.

Testing Fundamentals
high_coverage = {module: coverage for module, coverage in coverage_dict.items() if coverage [1] [2] and coverage [3] 1.0}
Drag options to blanks, or click blank then click option'
A>
B0.8
C<=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality operator which is too strict
Using wrong comparison directions