🔄
Logic Building - Phase 2: Looping & Patterns
Master loops, iteration, and pattern recognition with for and while loops
45 questions•5 pages•~68 min
Use this quiz track to strengthen recall, speed, and exam-style decision making. Attempt one page first, review explanations, and then re-attempt incorrect questions without notes.
A good scoring strategy is to mark uncertain questions, finish known ones quickly, and return with elimination logic. This improves accuracy while keeping momentum under time constraints.
Progress: 0 / 450%
Page 4 of 5 • Questions 31-40 of 45
Q31medium
What will be printed? sum_odd = 0 for i in range(1, 20, 2): sum_odd += i print(sum_odd)
Q32hard
What is the result?
n = 5
for i in range(n):
print(" " * (n-i-1) + "*" * (2*i+1))Q33medium
What will be printed? num = 12345 count = 0 while num: count += 1 num //= 10 print(count)
Q34medium
What does this code calculate? n = 8 fib = [0, 1] for i in range(2, n): fib.append(fib[i-1] + fib[i-2]) print(fib)
Q35easy
What is the output?
for i in range(1, 6):
if i == 3:
break
print(i)Q36easy
What will be printed? for i in range(5): print(i, i*i)
Q37hard
What is the result?
num = 7
perfect_sum = 0
for i in range(1, num):
if num % i == 0:
perfect_sum += i
print(perfect_sum == num)Q38hard
What will be printed? for i in range(3): for j in range(3): if i == j: print(1, end=" ") else: print(0, end=" ") print()
Q39hard
What does this code calculate? n = 10 harmonic = 0 for i in range(1, n+1): harmonic += 1 / i
Q40medium
What is the output?
for i in range(1, 5):
print(str(i) * i)...