Complete the code to avoid repeating the same logic in multiple places.
def calculate_area(radius): return [1] * radius * radius
Using a constant like pi avoids repeating the value everywhere.
Complete the code to reuse the function instead of repeating the calculation.
def get_discounted_price(price, discount): return price - (price * discount) final_price = [1](100, 0.1)
Calling get_discounted_price reuses the logic and avoids repetition.
Fix the error in the code to avoid repeating the same query logic.
def fetch_users(): query = "SELECT * FROM users WHERE active = 1" return [1](query) def fetch_admins(): query = "SELECT * FROM users WHERE active = 1 AND role = 'admin'" return execute_query(query)
Using the same function execute_query avoids repeating query execution logic.
Fill both blanks to create a reusable function and call it correctly.
def [1](data): processed = [x * 2 for x in data] return processed result = [2]([1, 2, 3])
Defining and calling the function process_data avoids repeating processing logic.
Fill all three blanks to create a reusable class method and use it properly.
class Calculator: def [1](self, a, b): return a + b calc = Calculator() result = calc.[2](5, 7) print([3])
Defining the method add, calling it, and printing the result avoids repeating addition logic.
