The output from this loop will be:
World
Hello
World
Hello
World
How to explain
The provided loop iterates through numbers from 1 to 5. If the number is even (i.e., divisible by 2), it prints "Hello"; otherwise, it prints "World".
Therefore, the output from this loop will be:
World
Hello
World
Hello
World
The loop prints "Hello" for even numbers and "World" for odd numbers in the range 1 to 5. The output alternates between "World" and "Hello."
The Complete Question
What is the output from the for loop presented below?
for i in range(1, 6):
if i % 2 == 0:
print("Hello")
else:
print("World")