Look at this number sequence:
2, 4, 8, 16, ...
What is the next number?
Each number is multiplied by 2 to get the next.
This sequence doubles each time: 2 × 2 = 4, 4 × 2 = 8, 8 × 2 = 16, so next is 16 × 2 = 32.
What does this code print?
for i in range(1, 6): print(i * '*')
Multiplying a string by a number repeats the string.
The loop prints 1 star, then 2 stars, up to 5 stars, each on a new line.
Which sequence follows the same pattern as this one?
3, 6, 12, 24, ...
Look for how each number changes to the next.
Both sequences multiply by 2 each time: 3×2=6, 6×2=12, etc. and 2×2=4, 4×2=8, etc.
A pattern adds the previous two numbers to get the next. Which is this pattern?
Think about a famous sequence where each number is sum of two before it.
The Fibonacci sequence starts with 0 and 1, then each number is the sum of the two before it.
What is the output of this code?
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))
Look at how the inner loop counts down from i to 1.
The code builds lines counting down from i to 1, so line 3 is '321', line 4 is '4321'.