DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

PYTHON-3 DAY -7

PYTHON TASK

  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.

Level 1 :

print(1,2,3,4,5)
Enter fullscreen mode Exit fullscreen mode

Level 2:

student=1
while student<=5:
    print(student)
    student=student+1
Enter fullscreen mode Exit fullscreen mode

output:
1
2
3
4
5

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

Level 1:

print(0,2,4,6,8)
Enter fullscreen mode Exit fullscreen mode

Level 2:

for i in range (0,10,2):
    print(i)
Enter fullscreen mode Exit fullscreen mode

output:
0
2
4
6
8

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

Level 1:

print(3,6,9,12,15)
Enter fullscreen mode Exit fullscreen mode

Level 2:

floor=3
while floor<=16:
    print(floor)
    floor=floor+3
Enter fullscreen mode Exit fullscreen mode

output:
3
6
9
12
15

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

Level 1:

print(10,8,6,4,2,0)
Enter fullscreen mode Exit fullscreen mode

Level 2:

for i in range(10,-1,-2):
    print(i)
Enter fullscreen mode Exit fullscreen mode
count=10
while count>=0:
    print(count)
    count=count-2
Enter fullscreen mode Exit fullscreen mode

output:
10
8
6
4
2
0

Top comments (0)