DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

PYTHON3 - TASK 1 day8

TASK:

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

PROGRAM:

  1. ODD JERSEY PROGRAM:
no=1
while (no<=10):
   print(no, end=' ')
   no=no+2
Enter fullscreen mode Exit fullscreen mode

output:
1,3,5,7,9

  1. EVEN JERSEY PROGRAM:
no=2
while(no<=10):
   print(no, end=' ')
   no=no+2
Enter fullscreen mode Exit fullscreen mode
  1. COMBINING TWO PROGRAM INTO A SINGLE PROGRAM:

(i) FLOWCHART:

(ii) PROGRAM:

no=1
while(no<=10):
   print (no, end=' ')
   no=no+2
   if(no==11):
   no=2
Enter fullscreen mode Exit fullscreen mode

output:
1,3,5,7,9,2,4,6,8,10

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

PROGRAM:

A) Daughter plan:

box=0
day=1
while day<=5:
   box=box+5
   day=day+1
print(box)
Enter fullscreen mode Exit fullscreen mode

output:
25

B) Father plan:

box=0
day=1
while day<=5:
   box=box+day
   day=day+1
print(box)
Enter fullscreen mode Exit fullscreen mode

output:
15

C) Display the both total for 10 days instead of 5 days

box=0
day=1
while day<=10:
   box=box+10
   day=day+1
print(box)
Enter fullscreen mode Exit fullscreen mode

output:
100

box=0
day=1
while day<=10:
   box=box+day
   day=day+1
print(box)
Enter fullscreen mode Exit fullscreen mode

output:
55

Top comments (0)