the average of the weights average_weight = sum(weights) / len(weights)
weights = []
for i in range(1, 5):
weight = float(input(f"Enter weight {i}: "))
weights.append(weight)
# Output the list of weights
print(f"Weights: {weights}")
print()
# Calculate and output the average of the weights
average_weight = sum(weights) / len(weights)
print(f"Average weight: {average_weight:.2f}")
print()
# Find and output the maximum weight in the list
max_weight = max(weights)
print(f"Max weight: {max_weight:.2f}")
print()
# Prompt the user to enter a location in the list and output the weight at that location in pounds and kilograms
location = int(input("Enter a list location (1 - 4): "))
weight_pounds = weights[location - 1]
weight_kilograms = weight_pounds / 2.2
print(f"Weight in pounds: {weight_pounds:.2f}")
print(f"Weight in kilograms: {weight_kilograms:.2f}")
print()
# Sort the list and output the sorted list
weights.sort()
print(f"Sorted list: {weights}")
Trending now
This is a popular solution!
Step by step
Solved in 2 steps