5.18 LAB: Smallest and largest numbers in a list Instructor note: Feel free to use Python's built-in min() and max() functions to solve this. The heart of this lab is the first part: constructing a list of values from user-entered input. Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smallest and largest integers in the list. Ex: If the input is: 10 21 2 -6 the output is: 2 and 21 You can assume that the list of integers will have at least 2 values.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

In python

5.18 LAB: Smallest and largest numbers in a list
Instructor note:
Feel free to use Python's built-in min() and max() functions to solve this. The heart of this lab is the first part: constructing a list of
values from user-entered input.
Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smallest and largest
integers in the list.
Ex: If the input is:
10
5
3
21
-6
the output is:
2 and 21
You can assume that the list of integers will have at least 2 values.
Transcribed Image Text:5.18 LAB: Smallest and largest numbers in a list Instructor note: Feel free to use Python's built-in min() and max() functions to solve this. The heart of this lab is the first part: constructing a list of values from user-entered input. Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smallest and largest integers in the list. Ex: If the input is: 10 5 3 21 -6 the output is: 2 and 21 You can assume that the list of integers will have at least 2 values.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I keep getting this 

l=[]
while(True):
    n=int(input())
    if(n<=0):
        break
    else:
        l.append(n)
print(min(l),"and",max(l))

Solution
Bartleby Expert
SEE SOLUTION
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning