Project: Smallest and largest

Write a program that asks how many numbers the user wants to enter (at least one), then asks for that many numbers. When all the numbers are in, print the smallest and the largest. Do not use lists or any other data structure. When you run it, the output should match this format:

How many numbers would you like to enter?
3
Please enter 3 numbers.
3
5
7

min: 3
max: 7

Hints: how many numbers do you need to keep track of at one time? If someone read you a list of numbers and asked for the largest and smallest at the end, what would you remember as you went? How should you set up your variables? What happens if the user enters only one number?

Save the file as min_max_number.py.

Show a solution

Try the project on your own first. This is one working solution. Press Run, and a box asks for each input. Type the sample values from the project description to see the same output.

These tests check the solution above. They run a copy of the program, kept in PROGRAM, and give it pretend input. The testing tools here are not part of the course yet, so do not worry about how they work. Read the test names and the expected outputs: together they list what the program must do. Press Run to run the tests.

Projects run on your own computer, so you tell us when you are done.