Complete the code to follow the DRY principle by avoiding repeated print statements.
def greet(name): print(f"Hello, {name}!") # Instead of repeating print, call [1]
Using a function like greet avoids repeating the print statement multiple times, following DRY.
Complete the sentence to explain the DRY principle.
"DRY means you should avoid [1] code."
DRY stands for "Don't Repeat Yourself," so it means avoiding repeating code.
Fix the error in the code to avoid repeating the calculation.
def area(radius): return 3.14 * radius [1] 2 # Use the function instead of repeating the formula
The exponent operator ** correctly calculates radius squared, avoiding repeating the multiplication.
Fill both blanks to create a dictionary comprehension that avoids repeating the length calculation.
lengths = {word: [1] for word in words if len(word) [2] 3}Using len(word) avoids repeating length calculation, and > filters words longer than 3.
Fill all three blanks to create a dictionary comprehension that avoids repeating keys and filters positive values.
result = { [1]: [2] for [1], [2] in data if [2] [3] 0 }Using k and v avoids repeating key and value names, and > filters positive values.