Question
A dancing competition is being held. Each competitor in this competition is judged by seven judges. Each judge submits a score (an integer between 0
A dancing competition is being held. Each competitor in this competition is judged by seven judges. Each judge submits a score (an integer between 0 and 100, including 0 and 100) and the competitor's score is the average of the seven judge's scores. Design a short Python program which will: Input the number of competitors. Your algorithm should repeat the input until thenumber of competitors input is between 3 and 16 (including 3 and 16). For each competitor, your program should:Input the judges' scores. If an input score is invalid, then your algorithm should repeat the input until the score is valid. Output the score for the competitor. Note the average is calculated as a real number. Note you must make good use of sub modules (functions) and control structures (if/while/for) as shown in the lectures and practical exercises.
As a guide to what is expected, have a look at the pseudocode below and convert it into Python. You should use at least one function to validate the values that are entered and make the code much cleaner. MAIN numJudges = 7 numCompetitors = inputValue <-- 3, 16, "Enter number of competitors (between 3 and 16 inc)" FOR comp = 0 TO numCompetitors-1 CHANGEBY 1 totalC = 0 OUTPUT input scores between 0 and 100 for each Judge FOR j = 0 TO numJudges-1 CHANGEBY 1 scoreJ = inputValue <-- 0, 100, "Score for judge " totalC = totalC + scoreJ ENDFOR scoreC = totalC / numJudges OUTPUT "Score for competitor , , is", scoreC ENDFOR END
SUBMODULE inputValue IMPORT lower, upper, prompt EXPORT value
INPUT value WHILE value < lower OR > upper DO OUTPUT Error OUTPUT prompt INPUT value ENDWHILE |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started