Question: For this task, you are to write code that calculates the height difference between the shortest and the tallest person. Instructions Your program should

For this task, you are to write code that calculates the height difference between the shortest and the tallest person. Instructions Your program should ask the user to input a number of people. The program should then repeatedly ask the user to input a person's height until the specified number of people is reached (using a for loop with a range). Finally, the program should output the height difference between the shortest and the tallest persons You must write the code which identify the shortest and tallest by yourself, updating variables as each new value is input by the user. You are not to place input values in a data structure or use predefined functions that perform aggregation. For example, a solution which places all of the values in a list and sorts the list can not achieve full marks. Hint: try starting with maximum aggregation (refer to the lecture materials) and work from there. Hint: the aggregation will require two summary variables. If the user inputs a number less than 2 for the number of people, the program should output a friendly message informing the user that at least 2 people are required. A function has already been defined for you which asks the user for the height of a person. You must use this function as part of your solution. Run 2 Number of people: 1 At least 2 people are required. Run 3 Number of people: 2 Enter the height of a person (cm): 190 Enter the height of a person (cm): 165 Height difference between the shortest and the tallest: 25 cm Your code should execute as closely as possible to the example runs above. To check for correctness, ensure that your program gives the same outputs as in the examples, as well as trying it with other inputs.
Step by Step Solution
3.42 Rating (158 Votes )
There are 3 Steps involved in it
Heres a Python program that follows the instructions to calculate the height difference between the ... View full answer
Get step-by-step solutions from verified subject matter experts
