Welcome to Westonci.ca, where you can find answers to all your questions from a community of experienced professionals. Explore a wealth of knowledge from professionals across different disciplines on our comprehensive platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
In Python:
nums = []
larg= []
small = []
while True:
for i in range(10):
num = int(input(": "))
nums.append(num)
print("Smallest: "+str(min(nums))); print("Largest: "+str(max(nums)))
larg.append(max(nums))
small.append(min(nums))
another = int(input("Press 1 to for another sets: "))
nums.clear()
if not another == 1:
break
print("Average Large: "+str(sum(larg)/len(larg)))
print("Average Small: "+str(sum(small)/len(small)))
Explanation:
This initializes the list of input numbers
nums = []
This initializes the list of largest number of each input set
larg= []
This initializes the list of smallest number of each input set
small = []
This loop is repeated until, it is exited by the user
while True:
The following iteration is repeated 10 times
for i in range(10):
Prompt the user for input
num = int(input(": "))
Add input to list
nums.append(num)
Check and print the smallest using min; Check and print the largest using max;
print("Smallest: "+str(min(nums))); print("Largest: "+str(max(nums)))
Append the largest to larg list
larg.append(max(nums))
Append the smallest to small list
small.append(min(nums))
Prompt the user to enter another set of inputs
another = int(input("Press 1 to for another sets: "))
Clear the input list
nums.clear()
If user inputs anything other than 1, the loop is exited
if not another == 1:
break
Calculate and print the average of the set of large numbers using sum and len
print("Average Large: "+str(sum(larg)/len(larg)))
Calculate and print the average of the set of smallest numbers using sum and len
print("Average Small: "+str(sum(small)/len(small)))
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. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.