Untitled
unknown
plain_text
4 months ago
819 B
8
Indexable
# 1. For loop to output odd integers <= 100
print("Odd numbers less than or equal to 100:")
for i in range(1, 101, 2):
print(i)
# 2. While loop to output even integers <= 100
print("\nEven numbers less than or equal to 100:")
num = 2
while num <= 100:
print(num)
num += 2
# 3. Loop to allow user to repeat
while True:
answer = input("\nDo you want to see the loops again? (yes/no): ").lower()
if answer == "yes":
print("\nOdd numbers less than or equal to 100:")
for i in range(1, 101, 2):
print(i)
print("\nEven numbers less than or equal to 100:")
num = 2
while num <= 100:
print(num)
num += 2
elif answer == "no":
print("Goodbye!")
break
else:
print("Please enter 'yes' or 'no'.")Editor is loading...
Leave a Comment