๐ Step-by-step explanation:
-
nums = [0, 1, 2, 3, 4]
-
A list of numbers from 0 to 4.
-
-
for i in nums:
-
Loop through each element in the list → i will take values 0, 1, 2, 3, 4.
-
-
if i in (1, 3):
-
Check if the current i is 1 or 3.
-
If True, then continue will skip the current iteration and move to the next number.
-
-
print(i**2, end=" ")
-
If not skipped, print the square of i.
end=" " means all results will be printed on the same line separated by spaces.
-
✅ Execution:
i = 0 → not in (1, 3) → print 0**2 = 0
i = 1 → in (1, 3) → skip
i = 2 → not in (1, 3) → print 2**2 = 4
i = 3 → in (1, 3) → skip
i = 4 → not in (1, 3) → print 4**2 = 16
Final Output:
0 4 16


0 Comments:
Post a Comment