0
0
Software Engineeringknowledge~10 mins

DRY (Don't Repeat Yourself) 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 follow the DRY principle by avoiding repeated print statements.

Software Engineering
def greet(name):
    print(f"Hello, {name}!")

# Instead of repeating print, call [1]
Drag options to blanks, or click blank then click option'
Agreet
Bprint
Chello
Drepeat
Attempts:
3 left
💡 Hint
Common Mistakes
Using print directly instead of calling the function.
2fill in blank
medium

Complete the sentence to explain the DRY principle.

Software Engineering
"DRY means you should avoid [1] code."
Drag options to blanks, or click blank then click option'
Arepeating
Bdeleting
Cwriting
Dcommenting
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'writing' which is too general.
3fill in blank
hard

Fix the error in the code to avoid repeating the calculation.

Software Engineering
def area(radius):
    return 3.14 * radius [1] 2

# Use the function instead of repeating the formula
Drag options to blanks, or click blank then click option'
A+
B*
C**
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which multiplies but is less clear than '**' for square.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that avoids repeating the length calculation.

Software Engineering
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' instead of 'len(word)' for the value.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that avoids repeating keys and filters positive values.

Software Engineering
result = { [1]: [2] for [1], [2] in data if [2] [3] 0 }
Drag options to blanks, or click blank then click option'
Ak
Bv
C>
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'item' which is not standard for keys or values.