For this task, you are to write code that calculates the height difference between the shortest...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program that follows the instructions to calculate the height difference between the ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
All research requires some level of funding and a budget should be included in the proposal (both quantitative and qualitative) even if outside funding is not being sought?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
Alleghany Community College operates four departments. The square footage used by each department is shown below. Alleghany's annual building rental cost is $320,000 What amount of rent expense that...
-
(a) The H C1 bond length is 136 pm. What would the dipole moment of HC1 be if the molecule were 100% ionic, H+ C1-? (b) The actual; dipole moment HC1 is 1.08 D. What is the percent ionic character...
-
If R is upper triangular and invertible, show that there exists a diagonal matrix D with diagonal entries 1 such that Rl = DR is invertible, upper triangular, and has positive diagonal entries.
-
An electron is fired into one end of the solenoid in Figure P28.66. Viewed along the positive \(x\) axis from a negative \(x\) coordinate, the electron enters from below at a \(65^{\circ}\) angle to...
-
Jackson Company produces plastic that is used for injection-molding applications such as gears for small motors. In 2016, the first year of operations, Jackson produced 4,000 tons of plastic and sold...
-
"Managing Away Bad Habits Team Assignment Organizational Behavior IILeadership Assigned is ashort case from the exercise Managing Away Bad Habits. The task is to develop a turnaround strategy for...
-
At 45C, 1,000 kg/h of a mixture of 0.80 mass fraction docosane and 0.20 mass fraction diphenylhexane is extracted with pure furfural to remove some diphenylhexane from the feed. Phaseequilibrium data...
-
Chip and Joanna Gaines are meeting with you as a loan officer, to discuss applying for a loan. They have seen a property at an open house they would like to buy but do not know if they can qualify....
-
Using the adjacency matrix for EmployeeGraph from Exercise 12, describe the path from Susan to Lance 1. using a breadth- first strategy. 2. using a depth-first strategy. Exercise 12 Extend the class...
-
1 2 4 5 7 3 6 8 is a traversal of the tree in which order? The numbers on the nodes are labels so that we can talk about the nodes; they are not key values within the nodes. 4 2 5 1 9 3 8
-
The numbers on the nodes are labels so that we can talk about the nodes; they are not key values within the nodes. 4 2 7 5 1 6 8 3 is a traversal of the tree in which order? 4 2 5 1 9 3 8
-
Show the contents of the array 2. SelectionSort 3. InsertionSort 43 [0] 7 [1] 10 [2] 23 [3] 18. [4] 4 [5] 19 [6] 5 [7] 66 [8] 14 [9]
-
Repeat Exercise 10, using the \(S\) chart in place of the \(R\) chart. Data From Exercise 10: A certain type of integrated circuit is connected to its frame by five wires. Thirty samples of five...
-
least? a 7. Supreme Scream is a ride in which passengers are dropped and experience the acceleration of gravity, before being rapidly brought to a complete stop. The ride reaches a height of 76.8...
-
Express these numbers in standard notation. a. 2.87 10-8 b. 1.78 1011 c. 1.381 10-23
-
Skyler is covered by his company's health insurance plan. The health insurance costs his company $3,500 a year. During the year, Skyler is diagnosed with a serious illness and the health insurance...
-
Fisafolia Corporation has gross income from operations of $220,000 and operating expenses of $160,000 for 2012. The corporation also has $20,000 in dividends from publicly traded domestic...
-
Calculate the amount of the child and dependent care credit allowed for 2012 in each of the following cases, assuming the taxpayers had no income other than the stated amounts. a. William and Carla...
-
The numbers of checked bags on flights between San Francisco and Atlanta. State whether the data described are discrete or continuous and explain why?
-
The speeds of cars as they pass the center of the Golden Gate Bridge. State whether the data described are discrete or continuous and explain why?
-
The numerical scores on a statistics test. State whether the data described are discrete or continuous and explain why?
Study smarter with the SolutionInn App