Westonci.ca is the premier destination for reliable answers to your questions, brought to you by a community of experts. Get immediate and reliable answers to your questions from a community of experienced professionals on our platform. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.
Sagot :
Answer:
The program in Python is as follows:
mynum = []
num = int(input("Enter a number: "))
total = 0
while num >= 0:
mynum.append(num)
total+=num
num = int(input("Enter a number: "))
print("Smallest: ",min(mynum))
print("Largest: ",max(mynum))
print("Average: ",total/len(mynum))
Explanation:
This creates an empty list
mynum = []
This prompts the user for input
num = int(input("Enter a number: "))
This initializes total to 0
total = 0
The following is repeated until a negative number is inputted
while num >= 0:
This appends the inputted number into the list
mynum.append(num)
This calculates the sum of all the numbers inputted
total+=num
This prompts the user for another input
num = int(input("Enter a number: "))
This calculates and prints the smallest
print("Smallest: ",min(mynum))
This calculates and prints the largest
print("Largest: ",max(mynum))
This calculates and prints the average
print("Average: ",total/len(mynum))
We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.