Complete the code to identify dead code by checking if a statement's result is {{BLANK_1}}.
if statement.result == [1]: print("Dead code detected")
Dead code is code whose result is never used, so checking for unused results helps identify it.
Complete the code to remove dead code by deleting statements that have no side effect.
for stmt in program.statements: if not stmt.has_side_effect and stmt.result == None: program.statements.remove([1])
To remove dead code, we delete the statement itself, so stmt is the correct choice.
Fix the error in the code that checks if a variable is dead by comparing its use count.
if variable.[1] == 0: mark_as_dead(variable)
A variable is dead if it is never used, so checking use_count equals zero is correct.
Fill both blanks to create a dictionary comprehension that maps variables to their usage count only if the count is zero.
dead_vars = {var: var.[1] for var in variables if var.[2] == 0}The dictionary maps variables to their use_count if the use_count is zero, indicating dead variables.
Fill all three blanks to create a dictionary comprehension that maps variable names in uppercase to their usage count, but only if the usage count is zero.
dead_vars = { [1]: [2] for var in variables if var.[3] == 0}The comprehension uses var.name.upper() as keys, var.use_count as values, and filters where use_count is zero.