0
0
Intro to Computingfundamentals~10 mins

Pattern recognition 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 print the first 5 even numbers.

Intro to Computing
for i in range(1, 11):
    if i [1] 2 == 0:
        print(i)
Drag options to blanks, or click blank then click option'
A%
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' instead of '%' causes a syntax or logic error.
Using '*' will multiply numbers, not check evenness.
2fill in blank
medium

Complete the code to find the sum of numbers from 1 to 5.

Intro to Computing
total = 0
for num in range(1, 6):
    total [1]= num
print(total)
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 adding.
Using '*' or '/' will cause incorrect calculations.
3fill in blank
hard

Fix the error in the code to print numbers from 1 to 5.

Intro to Computing
for i in [1](1, 6):
    print(i)
Drag options to blanks, or click blank then click option'
Adict
Blist
Cstr
Drange
Attempts:
3 left
💡 Hint
Common Mistakes
Using list alone does not generate numbers.
Using str or dict causes errors in loops.
4fill in blank
hard

Fill both blanks to create a dictionary of squares for numbers 1 to 5.

Intro to Computing
squares = {x[1]2: x[2]2 for x in range(1, 6)}
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 squaring.
Using '*' will multiply by 2, not square.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase words with their lengths, only for words longer than 3 letters.

Intro to Computing
result = { [1]: [2] for word in words if len(word) [3] 3}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of word.upper() for keys.
Using '<' instead of '>' causes wrong filtering.