Dev.to AI 🤖 Ai 👁 0

Tasks done in python

Self practiced Questions: 1) 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. stud = 1 while stud <= 5:

Self practiced Questions:

1) 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.

stud = 1
while stud <= 5:
    print(stud, end = ' ')
    stud = stud + 1

Output

1 2 3 4 5

2) A coach asks students to stand only at even-numbered positions in a queue. Display the first five positions.

coach = 2
while coach <= 10:
    print(coach, end = ' ')
    coach = coach + 2

Output

2 4 6 8 10

3) 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. A person enters the lift at the ground floor and presses the "Up" button. Display the first five floors where the lift will stop.

lift = 0
while lift <= 5:
    print(lift, end = ' ')
    lift = lift + 3

Output

0 3

4) A rocket launches with a countdown using only even numbers from 10. Display the countdown.

rocket = 10
while rocket >= 1:
    print(rocket, end = ' ')
    rocket = rocket - 2

Output

10 8 6 4 2
📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.