45.9k views
4 votes
(LAB) 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]

User Chadtatro
by
8.4k points

1 Answer

2 votes

# Get user input for weights

weight1 = float(input("Enter weight 1: "))

weight2 = float(input("Enter weight 2: "))

weight3 = float(input("Enter weight 3: "))

weight4 = float(input("Enter weight 4: "))

# Store weights in a list

weights = [weight1, weight2, weight3, weight4]

# Output list

print(f"Weights: {weights}")

```

User Khalid Ali
by
7.3k points

No related questions found