1) A teacher asks five students to stand in a line. Each student wears a badge with the number 1. Display the badge numbers from left to right.
student = 1
while student <= 5:
print(1, end = ' ')
student = student + 1
O/P:
1 1 1 1 1
2) Five students enter the classroom one after another. The first student gets roll number 1, the second gets 2, and so on. Display the assigned roll numbers.
roll = 1
while roll <= 5:
print("Assigned roll number:", roll )
roll = roll+1
O/P:
Assigned roll number: 1
Assigned roll number: 2
Assigned roll number: 3
Assigned roll number: 4
Assigned roll number: 5
3) A coach asks students to stand only at even-numbered positions in a queue. Display the first five positions.
num = 2
while num <= 10:
print("Evenu-No:", num)
num = num+2
O/P:
Evenu-No: 2
Evenu-No: 4
Evenu-No: 6
Evenu-No: 8
Evenu-No: 10
4) A newly constructed building has a special lift that does not stop on every floor. For safety reasons, it stops only at every third floor.
floor = 3
while floor <=15:
print("Floor-Lift:", floor)
floor = floor+3
O/P:
Floor-Lift: 3
Floor-Lift: 6
Floor-Lift: 9
Floor-Lift: 12
Floor-Lift: 15
5) A rocket launches with a countdown using only even numbers from 10. Display the countdown.
count = 10
while count >=0:
print("countdown:", count)
count = count-2
O/P:
countdown: 10
countdown: 8
countdown: 6
countdown: 4
countdown: 2
countdown: 0
Top comments (0)