Answer to Question #336657 in Python for Putsununu

Question #336657

write a python program to read in the number of judges at a competition and then read in the mark for each judge. Write out the highest mark, lowest mark and final mark.


The number of judges must be from 4 to 8.

Each judge can only give marks from 0.0 to 10.0


1
Expert's answer
2022-05-03T14:19:00-0400
# Checking that the number of judges should be between 4 and 8.
while True:
    number_of_judges = int(input('Input number of judges at a competition:'))
    if 4 <= number_of_judges <= 8:
        break
    else:
        print('The number of judges must be from 4 to 8.')

mark_list = []
judge = 1
# Checking that judge can only give marks from 0.0 to 10.0
while number_of_judges:
    mark = float(input(f'Mark {judge} judge:'))
    if 0 <= mark <= 10:
        mark_list.append(mark)
        number_of_judges -= 1
        judge += 1
    else:
        print('Each judge can only give marks from 0.0 to 10.0')


def highest_lowest_final_mark(lst):
    highest = max(lst)
    lowest = min(lst)
    final = round(sum(lst), 1)
    return f'Highest mark {highest}, lowest mark {lowest}, final mark {final}.'


print(highest_lowest_final_mark(mark_list))

i/o:
Input number of judges at a competition:10
The number of judges must be from 4 to 8.
Input number of judges at a competition:3
The number of judges must be from 4 to 8.
Input number of judges at a competition:5
Mark 1 judge:45
Each judge can only give marks from 0.0 to 10.0
Mark 1 judge:2
Mark 2 judge:8
Mark 3 judge:6.5
Mark 4 judge:8.5
Mark 5 judge:-3
Each judge can only give marks from 0.0 to 10.0
Mark 5 judge:0
Highest mark 8.5, lowest mark 0.0, final mark 25.0.


Process finished with exit code 0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS