Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago