✅ Explanation:
๐ for i in range(5)
This loop runs for values of i from 0 to 4 (i.e., 0, 1, 2, 3, 4).
if i % 2 == 0:This checks if the number is even.
% is the modulo operator (returns the remainder).
i % 2 == 0 means the number is divisible by 2 (i.e., even).
⏩ continue
If the number is even, continue tells the loop to skip the rest of the code in the loop body and move to the next iteration.
print(i)This line only runs if i is odd, because even values were skipped by the continue.
Loop Trace:
| i | i % 2 == 0 | Action |
|---|---|---|
| 0 | True | Skip (continue) |
| 1 | False | Print 1 |
| 2 | True | Skip (continue) |
| 3 | False | Print 3 |
| 4 | True | Skip (continue) |
✅ Output:
Application of Python Libraries in Astrophysics and Astronomy


0 Comments:
Post a Comment