Accept a list of 5 float numbers as an input from the user
Write a python program to accept a list of 5 float numbers as an input from the user and show them as output.
Write a python program to accept a list of 5 float numbers as an input from the user and show them as output.
[78.6, 78.6, 85.3, 1.2, 3.5]
numbersinput() function to take input from a userfloat() constructornumbers list using the append() function
numbers = []
# 5 is the list size
# run loop 5 times
for i in range(0, 5):
print("Enter number at location", i, ":")
# accept float number from user
item = float(input())
# add it to the list
numbers.append(item)
print("User List:", numbers)
Enter number at location 0 :
12
Enter number at location 1 :
34
Enter number at location 2 :
56
Enter number at location 3 :
78
Enter number at location 4 :
76
User List: [12.0, 34.0, 56.0, 78.0, 76.0]
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.