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,...

  • 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)...

  • Matlab fprintf help This is the question: I have already done part a, I need help...

    Matlab fprintf help This is the question: I have already done part a, I need help with part b. This is my current code: % array of Pounds to convert to Kilograms weight_pound = [50.543 65.676 75.343 80.937] % for Loop that calls from the array weight_pounds for index=1:4 %Convert weight from Pounds to Kilograms     weight_kg = weight_pound*0.453592 %Print out the conversion % ‘%5.2f’ for 2 decimals for Kilograms % ’%5.0f’ for no decimals in pounds     fprintf(‘%5.2f kg...

  • Write the Script in Python. courseCategories = ["Mathematics","Computer Science","Business","Economics","Literature","Art","Music"] Sample of the output. It should look...

    Write the Script in Python. courseCategories = ["Mathematics","Computer Science","Business","Economics","Literature","Art","Music"] Sample of the output. It should look same as the output. 'SR' - Sort a. b. 1. This operation will display the list before being sorted Display the list to the user after being sorted 2. 'CC-Character Count This operation will prompt the user for an index as an integer that will be the location to reference in the list If the integer is less than 0 or greater than the...

  • Hi please help with c++ programming. This is my code. there's a syntax error. PLEASE FIX...

    Hi please help with c++ programming. This is my code. there's a syntax error. PLEASE FIX MY CODE instead of re-designing the program. Thanks /*    Description of problem: Introduction to Friends functions. Create objects in the stack (not on the heap) 3.1: Add a friend function, kilotopound, which will convert kilograms to pounds. 3.2: Add a copy constructor utilizing Lab 3.1 code. Copy the fist object using a copy constructor. Output the contents of both objects. */ #include <iostream>...

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
ADVERTISEMENT