0
0
Intro to Computingfundamentals~10 mins

Abstraction (focusing on what matters) in Intro to Computing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple function that hides details and shows only the result.

Intro to Computing
def add_numbers(a, b):
    return a [1] b
Drag options to blanks, or click blank then click option'
A/
B-
C+
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' will subtract instead of add.
Using '*' or '/' will multiply or divide, not add.
2fill in blank
medium

Complete the code to call the function and print the result, focusing on what matters.

Intro to Computing
result = add_numbers(5, 3)
print([1])
Drag options to blanks, or click blank then click option'
A5 + 3
Bresult
Cadd_numbers
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the function name instead of the result.
Printing the expression directly instead of the stored result.
3fill in blank
hard

Fix the error in the function to properly abstract the calculation.

Intro to Computing
def multiply_numbers(a, b):
    result = a [1] b
    return result
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' will add or subtract instead of multiply.
Using '/' will divide instead of multiply.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that abstracts word lengths greater than 4.

Intro to Computing
{word [1] '_length': len(word) for word in words if len(word) [2] 4}
Drag options to blanks, or click blank then click option'
A**
B>
C<
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will select shorter words.
Using '**' is for power, not needed here.
5fill in blank
hard

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

Intro to Computing
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
Drag options to blanks, or click blank then click option'
Ak.lower()
Bv
C>
Dk.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k.lower()' changes keys to lowercase.
Using '<' filters negative values instead.