Q:

Write python program which repeatedly reads positive numbers until the user enters -1. once -1 is entered, print out both the maximum and minimum of the numbers

0

Write python program which repeatedly reads positive numbers until the user enters -1. once -1 is entered, 

print out both the maximum and minimum of the numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

print ('Hello World')
maximum=None
minimum=None
while True:
    number=int(input('enter a positive number:'))
    if number==-1:
        break
    elif number<-1:
        continue
    if maximum ==None or number>maximum:
        maximum=number
    if minimum ==None or number<minimum:
        minimum=number
    print('minimum is :',minimum)
print('highest entered number is :',maximum)
print('lowest entered number is :',minimum)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now