DEV Community

vidhya murali
vidhya murali

Posted on

Loops in Python

  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.

using for Loop:

using while Loop :

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

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

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

Top comments (0)