ella3714
05.05.2020 •
Computers and Technology
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 (2) Also output the total weight, by summing the array's elements. (1 pt) (3) Also output the average of the array's elements. (1 pt) (4) Also output the max array element. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 Total weight: 726.8 Average weight: 145.35999999999999 Max weight: 236.0
Solved
Show answers
More tips
- F Food and Cooking 10 Reasons Why You Should Avoid Giving Re-Gifts: An Informative Guide...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- A Animals and plants How to Grow Lime from a Seed: Simple Tips and Interesting Facts...
- C Computers and Internet How to Create a Folder on Your iPhone?...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
Answers on questions: Computers and Technology
- S Spanish In this activity, you will record your daily schedule and a relative’s or friend’s schedule, in spanish, using any audio recording software. use reflexive verbs and include...
- M Mathematics Which trasformation from the graph of a function f(x) describes the graph of 1/3 f(x)?...
- E English Kyle cried out in pain just like a wolf howling at the moon. Is this a simile or metaphor?...
Ответ:
weights = []
total = 0
max = 0
for i in range(5):
weight = float(input("Enter weight " + str(i+1) + ": "))
weights.append(weight)
total += weights[i]
if weights[i] > max:
max = weights[i]
average = total / 5
print("Your entered: " + str(weights))
print("Total weight: " + str(total))
print("Average weight: " + str(average))
print("Max weight: " + str(max))
Explanation:
Initialize the variables
Create a for loop that iterates 5 times
Get the values from the user
Put them inside the array
Calculate the total by adding each value to the total
Calculate the max value by comparing each value
When the loop is done, find the average - divide the total by 5
Print the results
Ответ:
It's B.
Explanation: