21. What is the purpose of the continue statement in loops?
22. What is the output of the following code snippet:
for i in range(3, 0, -1):
print(i)
for i in range(3, 0, -1):
print(i)
23. In Python, which loop is commonly used when you have a specific condition to break the loop?
24. What will the following code print:
x = 5
while x > 0:
print(x)
x -= 1
x = 5
while x > 0:
print(x)
x -= 1
25. What is the output of the following code:
x = 0
while x < 5:
print(x)
x += 1
x = 0
while x < 5:
print(x)
x += 1
26. What is the purpose of the pass statement in a loop?
27. In Python, which loop is suitable for cases where you need to execute a block of code multiple times until a condition is met?
28. What is the output of the following code snippet:
for i in range(1, 5, 2):
print(i)
for i in range(1, 5, 2):
print(i)
29. What will the following loop print:
for i in range(3):
print(i)
for i in range(3):
print(i)
30. What is the output of the following code snippet:
count = 0
while count < 3:
print("Hello")
count += 1
count = 0
while count < 3:
print("Hello")
count += 1