At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A 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 time on our site. Don't hesitate to return whenever you have more questions or need further clarification. Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.