I need a single FUNCTIONING code in PYTHON please :) 8.16 Ch 8 Warm up: People\'
ID: 3591536 • Letter: I
Question
I need a single FUNCTIONING code in PYTHON please :)
8.16 Ch 8 Warm up: People's weights (Lists) (Python 3)
(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts)
Ex:
(2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (1 pt)
(3) Output the max list element with two digits after the decimal point. (1 pt)
Ex:
(4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts)
Ex:
(5) Sort the list's elements from least heavy to heaviest weight. (2 pts)
Ex:
# FIXME (1): Prompt for four weights. Add all weights to a list. Output list.
# FIXME (2): Output average of weights.
# FIXME (3): Output max weight from list.
# FIXME (4): Prompt the user for a list index and output that weight in pounds and kilograms.
# FIXME (5): Sort the list and output it.
Explanation / Answer
Hello
please give thumbs up if you like it
# code start from here all the scenerio are in one code
weight = []
for i in range(1,5):
w = float(input('Enter weight {}: '.format(i)))
weight.append(w)
print('Weights:',weight)
print()
print('Average weight:',sum(weight)/4)
print('Max weight: ',max(weight))
print()
j = int(input('Enter a list index location between 1 and 4: '))
print()
print('Weight in pounds:',weight[j-1])
print('Weight in kilograms:',weight[j-1]/2.2)
print()
print('Sorted list:',sorted(weight))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.