Please note that on the last line of the code, we need to print out the 'and" with the smallest and the largest number for min and max functions in order to maximize our credit with the zyBooks lab assignment for 3.9. Code Hints: smallestnum = min(usernumbers) #The smallest number is printed out - for example 5, 10, 15 - 5 would be printed out largestnum = max(usernumbers) #The largest number is printed out - for example 5, 10, 15 - 15 would be printed out Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the list values and the smallest and largest integers in the list using min and max built-in functions . This code runs in zyBooks
Please note that on the last line of the code, we need to print out the 'and" with the smallest and the largest number for min and max functions in order to maximize our credit with the zyBooks lab assignment for 3.9.
Code Hints: smallestnum = min(usernumbers) #The smallest number is printed out - for example 5, 10, 15 - 5 would be printed out largestnum = max(usernumbers) #The largest number is printed out - for example 5, 10, 15 - 15 would be printed out
Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the list values and the smallest and largest integers in the list using min and max built-in functions . This code runs in zyBooks.....
Ex: If the input is:
10 5 3 21 2 -6
the output is:
[10, 5, 3, 21, 2] 2 and 21
user_numbers = []
user_input = int(input())
while user_input > 0:
user_numbers.append(user_input)
user_input = int(input())
print(user_numbers)
''' Complete code here. '''
smallest_num=min(user_numbers)
largest_num = max(user_numbers)
print(user_numbers)
print(smallest_num, ‘and’, largest_num)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images