Question

Hi,

I need some help with the following question. I need the answer in Python please. 10.23 LAB: Warm up: Peoples weights (Lists) (1) Prompt the user to enter four numbers, each corresponding to a persons weig

(4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding valu

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# list to store the weights
weights = []
# variable to store the average
average = 0

# for loop to get the values from the user
for i in range(4):
print("Enter weight "+str(i+1)+":")
# taking the input from the user
weight = float(input())
average = average + weight
# appending the weight value to weights list
weights.append(weight)
print("Weights: ",end='')
print(weights)
# Finding the average og the
average = average / 4   

# printing the Average value
print("\nAverage weight: %.2f" % average)

# printing the Max value
print("Max weight: %.2f" % max(weights) + "\n")

# taking user choice to shoe the weight
print("Enter a list location (1 - 4):")
choice = int(input())
# checking whether user entered the correct value or not

if choice >=1 and choice <=4:
# printing the weight in pounds
print("Weight in pounds: %.2f " % weights[choice-1])
# printing the weight in kg
print("Weight in kilograms: %.2f " % (weights[choice -1]/2.2))
else:
print("You have entered the wrong value.")
# printing the sorted list
print("\nSorted list: ", end='')
print(sorted(weights))

# list to store the weights weights = [] # variable to store the average 2 4 average = 0 5 # for loop to get the values fromroot@kali:~/Desktop/codes# python3 weight.py Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4:

Add a comment
Know the answer?
Add Answer to:
Hi, I need some help with the following question. I need the answer in Python please....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7...

    Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7 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: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements...

  • ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in...

    ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in Python about People's Weights. Here is the question: 10.23 LAB: Warm up: People's weights (Lists) (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: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]...

  • 5.18 Ch 5 Warm up: People's weights (Vectors) (C++) (1) Prompt the user to enter five...

    5.18 Ch 5 Warm up: People's weights (Vectors) (C++) (1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in a vector of doubles. Output the vector'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 89.5 142 166.3 93 (2) Also output the total weight, by summing...

  • 5.23 LAB: Warm up: People's weights (1) Prompt the user to enter five numbers, being five...

    5.23 LAB: Warm up: People's weights (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....

  • 14.5 Prog 5: People's weights (arrays) JAVA (1) Prompt the user to enter five numbers, being...

    14.5 Prog 5: People's weights (arrays) JAVA (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...

  • Need a basic program in C using the instructions above. Thanks. (1) Prompt the user to...

    Need a basic program in C using the instructions above. Thanks. (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 Enter weight 2: 89.5 Enter weight 3: 142 Enter weight 4: 166.3 Enter weight 5: 93 You entered 236.000000 89.500000 142.000000 166.300000 93.000000 (2) Also output the total weight,...

  • 11.6 Week 8 Lab: Arrays Boulder Weights Solve in C! (1) Prompt the user to enter...

    11.6 Week 8 Lab: Arrays Boulder Weights Solve in C! (1) Prompt the user to enter an integer for the number of boulders they have (assume the value is always less than 50). Then, prompt the user to enter that many numbers, representing the boulders’ weights. Store the weights in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) (2) Also output the total weight, by summing the array's elements....

  • I cannot seem to find a single answer to this question. The output of this code...

    I cannot seem to find a single answer to this question. The output of this code is You entered: 236.0 89.5 142.0 166.3 93.0 with a trailing space at the end of the number 93.0. These inputs are changed and always have a trailing space on the last number. Now, I know it's because I have System.out.print(m[i] + " "); with the " " creating the space in between each number. How do I write it so each number has...

  • I need help with this exercise, it keeps failing in generating to much results. Warm up:...

    I need help with this exercise, it keeps failing in generating to much results. Warm up: Parsing strings (C++) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the...

  • Write a single C++ program that performs the following conversion (The modulus divide will help you...

    Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT