DEV Community

Kiruthiga S
Kiruthiga S

Posted on

Python

6) In a school sports event, all students wearing ODD jersey numbers enter the ground first. After they finish, students with EVEN jersey numbers enter. Display the order.

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

n = 2
while n <= 10:
    print(n, end=' ')
    n = n + 2
Enter fullscreen mode Exit fullscreen mode

Output:1 3 5 7 9 2 4 6 8 10

7) A daughter is going on a 5-day vacation. She asks her father to give her ₹5 every day, so she can save the money.
Her father suggests a different plan. Instead of giving her ₹5 daily, he says:

Day 1: ₹1
Day 2: ₹2
Day 3: ₹3
Day 4: ₹4
Day 5: ₹5

The daughter agrees to her father's proposal.
Write a program to calculate:
A) The total amount the daughter would receive under her original plan.
B) The total amount she would receive under her father's plan.
C) Display both totals.
Redo the same activity for 10 days leave, instead of 5 days.

# A) Original plan
day = 1
daughter = 0

while day <= 5:
    daughter = daughter + 5
    day = day + 1
    # print("daughter:",daughter)

# B) Father's plan
day = 1
father = 0

while day <= 5:
    father = father + day
    day = day + 1
    # print("father:",father)

# C) Display both totals
print("Original plan =", daughter)
print("Father's plan =", father)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)