Module 3 challenge: Loops :Crash Course on Python (Google IT Automation with Python Professional Certificate) Answers 2025
1. Even numbers 2–12
✔️ Correct code:
number = 2
while number <= 12:
print(number, end=" ")
number += 2
2. Correct the loop
✔️ Correct loop:
for number in range(2, 13, 2):
print(number)
3. factorial(n)
✔️ Answers:
-
While condition →
n > 0 -
Decrement →
n -= 1
4. multiplication_table
✔️ Ranges:
-
Outer →
range(start, stop+1) -
Inner →
range(start, stop+1)
5. divisible(max, divisor)
✔️ Fill-ins:
-
Initialize →
count = 0 -
Loop →
for x in range(max): -
Increment →
count += 1
6. even_numbers(maximum)
✔️ Correct loop:
for x in range(2, maximum+1, 2):
return_string += str(x) + " "
7. Uninitialized loop variable
✔️ NameError ✔️
8. Final value of x
Loop: range(1, 10, 3) → values: 1, 4, 7
Final printed = 7, final value of x = 7 ✔️
9. Initial value of outer_loop
✔️ outer_loop starts at 2
10. Infinite loop reason
✔️ Variable x is not incremented
📌 Summary Table
| Q | Final Answer |
|---|---|
| 1 | number = 2, while number <= 12, number += 2 |
| 2 | for number in range(2, 13, 2): |
| 3 | while n > 0, n -= 1 |
| 4 | range(start, stop+1) for both loops |
| 5 | count = 0, for x in range(max), count += 1 |
| 6 | range(2, maximum+1, 2) |
| 7 | NameError |
| 8 | 7 |
| 9 | 2 |
| 10 | x is not incremented |