Question

In Python build a program that first accepts a single integer from the user that represents...

In Python build a program that first accepts a single integer from the user that represents how many inputs to read. If the user enters 0 or a negative number, simply stop the program without providing any output.

If the user inputs a positive integer as the first input, the program should continue to read that many integers from input, and then print the maximum and minimum inputs provided by the user in a format similar to the following:

Maximum: 15
Minimum: 12
0 0
Add a comment Improve this question Transcribed image text
Answer #1
n = int(input())
if n > 0:
    largest = None
    smallest = None
    for i in range(n):
        num = int(input())
        if largest is None or num > largest:
            largest = num
        if smallest is None or num < smallest:
            smallest = num
    print("Maximum:", largest)
    print("Minimum:", smallest)

Add a comment
Know the answer?
Add Answer to:
In Python build a program that first accepts a single integer from the user that represents...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT