45.7k views
2 votes
Write a program that will accept n number of integers from the keyboard. When the loop exits output the largest and smallest value entered. Note: Be careful, it is not appropriate to initialize the variables that hold the largest and smallest values to 0 as your first number. If you think about it if all values entered are greater than 0 then your program will output 0 as the smallest number and this was not a number that was entered.

Required: The only decisions staments allowed inside the loop are to determine the largest and smallest value. This means you are not allowed to use a decision to determine if the first number was entered. This is going to require you to prime your loop.

1 Answer

2 votes

Answer:

Step-by-step explanation:

n = eval(input('Enter # of number you want to enter: '))

list_=[]

for i in range(n):

number = eval(input("enter number: "))

list_.append(number)

if i == n-1:

maximum = max(list_)

minimum = min(list_)

print("maximum : "+str(maximum))

print("minimum : "+str(minimum))

Write a program that will accept n number of integers from the keyboard. When the-example-1
User Rii
by
6.4k points