0
0
Intro to Computingfundamentals~10 mins

Decomposition (breaking problems down) 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 show the first step in breaking down a problem: identifying the main {{BLANK_1}}.

Intro to Computing
def solve_problem():
    # Step 1: Identify the main [1]
    pass
Drag options to blanks, or click blank then click option'
Asteps
Bproblem
Csolution
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the problem with the solution.
Trying to write code before understanding the problem.
2fill in blank
medium

Complete the code to represent breaking a problem into smaller {{BLANK_1}}.

Intro to Computing
def decompose_problem():
    # Break the problem into smaller [1]
    parts = ['part1', 'part2', 'part3']
    return parts
Drag options to blanks, or click blank then click option'
Aproblems
Bsolutions
Csteps
Dresults
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'solutions' instead of 'steps'.
Thinking the smaller parts are separate problems.
3fill in blank
hard

Fix the error in the code by completing the blank to correctly represent a step in decomposition.

Intro to Computing
def plan_solution():
    # Each [1] should be simple and clear
    steps = ['understand problem', 'design solution', 'test solution']
    return steps
Drag options to blanks, or click blank then click option'
Astep
Bproblem
Csolution
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'solution' instead of 'step'.
Confusing 'problem' with 'step'.
4fill in blank
hard

Fill both blanks to complete the dictionary comprehension that maps each {{BLANK_1}} to its {{BLANK_2}} length.

Intro to Computing
lengths = {step: len(step) for step in [1] if len(step) > [2]
Drag options to blanks, or click blank then click option'
Asteps
B3
Cproblem
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'problem' instead of 'steps' for the iterable.
Using a string instead of a number for the length filter.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each {{BLANK_1}} in uppercase to its {{BLANK_2}} if the length {{BLANK_3}} 4.

Intro to Computing
result = { [1]: [2] for [2] in steps if len([2]) [3] 4 }
Drag options to blanks, or click blank then click option'
Astep.upper()
Bstep
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original step as key instead of uppercase.
Using '<' instead of '>' in the length condition.