0
0
Intro to Computingfundamentals~20 mins

Pattern recognition in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pattern Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Identify the next number in the sequence

Look at this number sequence:

2, 4, 8, 16, ...

What is the next number?

A24
B20
C18
D32
Attempts:
2 left
💡 Hint

Each number is multiplied by 2 to get the next.

trace
intermediate
1:30remaining
Trace the pattern in the code output

What does this code print?

Intro to Computing
for i in range(1, 6):
    print(i * '*')
A
1
2
3
4
5
B
*****
****
***
**
*
C
*
**
***
****
*****
DError: cannot multiply string by int
Attempts:
2 left
💡 Hint

Multiplying a string by a number repeats the string.

Comparison
advanced
1:30remaining
Compare patterns in two sequences

Which sequence follows the same pattern as this one?

3, 6, 12, 24, ...

A2, 4, 8, 16, 32
B3, 9, 27, 81, 243
C5, 10, 15, 20, 25
D1, 3, 6, 10, 15
Attempts:
2 left
💡 Hint

Look for how each number changes to the next.

identification
advanced
1:00remaining
Identify the pattern type from a description

A pattern adds the previous two numbers to get the next. Which is this pattern?

AFibonacci sequence
BGeometric sequence
CArithmetic sequence
DPrime numbers
Attempts:
2 left
💡 Hint

Think about a famous sequence where each number is sum of two before it.

🚀 Application
expert
2:00remaining
Predict the output of a complex pattern code

What is the output of this code?

Intro to Computing
def pattern(n):
    result = []
    for i in range(1, n+1):
        line = ''.join(str(x) for x in range(i, 0, -1))
        result.append(line)
    return '\n'.join(result)

print(pattern(4))
A
1
12
123
1234
B
1
21
321
4321
C
4
43
432
4321
DError: invalid syntax
Attempts:
2 left
💡 Hint

Look at how the inner loop counts down from i to 1.