Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write this in PYHTON! and as simple as possible People's Weights Overview In this program, you will use incremental development to manipulate a list.

Please write this in PYHTON! and as simple as possible
People's Weights
Overview
In this program, you will use incremental development to manipulate a list.
Objectives
Be able to:
Get a list of numbers
Display the individual numbers of a list
Find the average and maximum of the numbers in a list
Perform calculations on a number in a list
Sort a list
Description
In this problem, you will first need to prompt for how many weights should be added to a list. You will gather the weights (in pounds) from input one at a time adding them to a list. There will be the same number of weights to get from input as the first inputted number. From here, display the list to the user along with the average and maximum weights. Next, ask the user for a location in the list and convert that weight to kilograms and display the converted weight. Following this, sort and display the list again. Finally, display the list of weights again, along with what the weights would be on Mars.
Note: Use the built in Python function round() to round the weights to 1 decimal point after any calculation has been performed on them. The way the Python round() function works is that it takes the item to be rounded as the first argument, and the number of decimal places as the second argument. So if you have a variable x that contains the value 3.485719 round(x,1) would return a value of 3.5.
One run of the full program is as follows:
Enter the number of weights: 4
Enter a weight:
236.0
Enter a weight:
89.5
Enter a weight:
176.0
Enter a weight:
166.3
Weights: [236.0,89.5,176.0,166.3]
Average weight: 166.9
Max weight: 236.0
Enter a list location:
3
Weight in pounds: 176.0
Weight in kilograms: 80.0
Sorted list: [89.5,166.3,176.0,236.0]
Weight on Earth: [89.5,166.3,176.0,236.0]
Weight on Mars: [33.9,62.9,66.6,89.3]
Think about how you would do this before you continue reading. Come up with pseudocode for how you would solve this problem. Then see if it follows the same logic presented here. If you do not know where to start, read the first step below and then try to construct the rest of the program on your own. Commonly, the hardest part of writing a program is knowing where to start. Try to begin without using the guide below. If you need more information on how to convert pounds to kilograms or how to convert the weight on earth to the weight on Mars, look at steps 4 and 6 below.
(1) Prompt the user for the number of weights and then prompt the user to enter the weights, each corresponding to a persons weight in pounds. Store all the weights in a list. Output the list.
Ex:
Enter the number of weights: 4
Enter a weight:
236.0
Enter a weight:
89.5
Enter a weight:
176.0
Enter a weight:
166.3
Weights: [236.0,89.5,176.0,166.3]
(2) Output the average of the lists elements with one digit after the decimal point.
Ex (using inputs above):
Average weight: 166.9
(3) Output the max list element with one digit after the decimal point.
Ex (using inputs above):
Max weight: 236.0
(4) Prompt the user for a number between 1 and the number of weights in the list. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds.
NOTE List indexing starts at 0. This number starts at 1. You will need to make the number match the correct list location.
Ex (using inputs above):
Enter a list location:
3
Weight in pounds: 176.0
Weight in kilograms: 80.0
(5) Sort the lists elements from least heavy to heaviest weight.
Ex:
Sorted list: [89.5,166.3,176.0,236.0]
(6) Create another list for the weights on Mars. To compute weight on Mars, take the weight on Earth and divide by Earths gravitational force, which is 9.81. Then multiply by the Mars gravitational force, which is 3.711.
Print out each set of weights as follows:
Ex: If the sorted list of weights is [89.5,166.3,176.0,236.0]
Weight on Earth: [89.5,166.3,176.0,236.0]
Weight on Mars: [33.9,62.9,66.6,89.3]
(7) Congratulate yourself on a job well done!

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions