Write a Python program that will do the following: 1) Ask the user for how many
ID: 3724095 • Letter: W
Question
Write a Python program that will do the following:
1) Ask the user for how many values they would like to enter. This value must be between 1 and 15, inclusive (enforce the range.) Hereafter this quantity will be known as “numValues”.
2) Create a list of numValues values(floats) by calling a function named input_nums(). That function, which is called just once, will handle the input of the numValues values and storing them into a list that it returns.
*All numbers need to be printed to (only) one decimal place.*
Explanation / Answer
def input_nums(n):
lst = []
for i in range(n):
value = float(input("Enter the number: "))
lst.append(value)
return lst
numValues = int(input("Enter the number of values: "))
lst = input_nums(numValues)
for i in range(len(lst)):
print(round(lst[i],1))
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.