loop output based questions
loop output based questions
1. Question 1:
i=1
while i < 5:
print(i, end=" ")
i += 1
2. Question 2:
for i in range(3):
print(i, end=", ")
3. Question 3:
x = 10
while x > 5:
print(x, end=" ")
x -= 2
4. Question 4:
5. Question 5:
i=0
while i < 10:
i += 3
print(i, end=" ")
6. Question 6:
7. Question 7:
count = 1
while count <= 3:
for i in range(1, count+1):
print(i, end="")
print()
count += 1
8. Question 8:
for i in range(4):
for j in range(i+1):
print("*", end="")
print()
9. Question 9:
i=1
while i < 4:
j=1
while j < 3:
print(i*j, end=" ")
j += 1
i += 1
x=0
while x < 10:
print(x, end=" ")
x += 2
i=5
while i >= 1:
print(i * "#")
i -= 1
i=1
while i <= 10:
if i % 2 == 0:
print(i, end=", ")
i += 1
i = 10
while i >= 2:
print(i, end=" ")
i -= 3
x=0
while x < 5:
for y in range(x):
print(y, end="")
print()
x += 1
python
Copy code
for i in range(3):
for j in range(i, 3):
print(j, end=" ")
print()