Answered step by step
Verified Expert Solution
Question
1 Approved Answer
using python plz Worksheet 3 & 4 Worksheet 3 While Loops To pass this exercise you must demonstrate that you are able to do the
using python plz
Worksheet 3 & 4 Worksheet 3 While Loops To pass this exercise you must demonstrate that you are able to do the following in solving the problem O EXPLAIN HOW YOUR PROGRAM WORKS Write a program that correctly uses while loops Include simple comments - at least the actual author's name and date Paralympic Swimming relay Paralympic swimming relay competitions involve competitors of different disability levels making up a team. For those with physical disabilities, each swimmer's disability is rated on a scale of 1-10 and the total points rating for the 4 swimmers must be no greater than a given number of points. For example, a legal relay team for a 34-point freestyle relay may consist of two S8 swimmers and two S9 swimmers (9+9+ 8 + 8 = 34), or an S10 swimmer and three S8 swimmers (10 + 8 + 8 + 8 = 34). Write a program that uses a loop to work out the total disability point score for a single team and check that it is legal, for a given point score relay. HINT: Have a variable that keeps a running total. The program must be split in to functions that take arguments and return results in a sensible way. One function should take the swimmer's number (1-4) as argument and ask for and return the number the user inputs (that swimmer's disability category). Another function should calculate the legality of the team, when given as an argument the total of the four disability classes and the maximum total allowed. The following is an example run of the program What is the classification (maximum points) of this relay event? 34 What is the disability category of Swimmer 1? 10 What is the disability category of Swimmer 2? 8 What is the disability category of Swimmer 37 8 What is the disability category of Swimmer 4? 8 That team has 34 points so is legal The following is another example run of the program What is the classification (maximum points) of this relay event? 32 What is the disability category of Swimmer 17 9 What is the disability category of Swimmer 27 9 What is the disability category of Swimmer 37 8 What is the disability category of Swimmer 4? 7 That team has 33 points so is NOT legal GRADING Your program will be marked taking into account the next boxes The program runs correctly. [10 marks) Running totals are correct at all points through the loop [20 marks) The program uses a while loop construct and does the correct number of iterations [20 marks) As with the if statements, loops execute code depending on a test. You need to check that the loop does execute exactly the right number of times every time. Make sure loops can't run forever for any input (including input the programmer didn't think of the user ever entering such as empty strings, zero and negative numbers. You can include print statements in the code, so that when you run it, you get some feedback on what the code is doing. Perhaps This is the in time through this loop", etc 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