0
0
Software Engineeringknowledge~10 mins

Code coverage metrics in Software Engineering - 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 the percentage of lines covered by tests.

Software Engineering
coverage_percentage = (covered_lines / [1]) * 100
Drag options to blanks, or click blank then click option'
Atotal_lines
Btest_lines
Cuncovered_lines
Dexecuted_lines
Attempts:
3 left
💡 Hint
Common Mistakes
Using test lines instead of total lines
Using uncovered lines as denominator
2fill in blank
medium

Complete the code to filter out functions that have zero coverage.

Software Engineering
functions_with_coverage = {f: c for f, c in coverage_data.items() if c > [1]
Drag options to blanks, or click blank then click option'
A0
B1
C-1
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 excludes functions with partial coverage
Using 100 excludes all but fully covered functions
3fill in blank
hard

Fix the error in the code to calculate branch coverage correctly.

Software Engineering
branch_coverage = (covered_branches / [1]) * 100
Drag options to blanks, or click blank then click option'
Atotal_lines
Btotal_branches
Ccovered_branches
Dexecuted_branches
Attempts:
3 left
💡 Hint
Common Mistakes
Using covered branches as denominator
Using total lines instead of branches
4fill in blank
hard

Fill both blanks to create a dictionary of functions with coverage above 80%.

Software Engineering
high_coverage_funcs = {f: c for f, c in coverage_data.items() if c [1] [2]
Drag options to blanks, or click blank then click option'
A>
B80
C>=
D75
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' includes 80% exactly
Using 75 is too low threshold
5fill in blank
hard

Fill all three blanks to create a summary dictionary with function names in uppercase and coverage above 50%.

Software Engineering
summary = { [1]: [2] for func, cov in coverage_data.items() if cov [3] 50 }
Drag options to blanks, or click blank then click option'
Afunc.upper()
Bcov
C>
Dfunc.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using func.lower() instead of upper
Using '<' instead of '>' for filtering