Lesson goal: Data Science: Initial values for max and min

Previous: Find the minimum value | Home | Next: Visualize data with a plot

From the last two lessons on finding the minimum and maximum value of some numbers, you might have a lingering thought: were your choices for the inital values of the variables max and min the best? Would you code work in all cases? Was your code 'robust?'

As an example, suppose you set your min initially to 100, but suppose your data file contained a bunch of numbers that were all only in the 1000s? Your code would say 100 was in the minimum, but 100 isn't even in the data file!

Alternatively, suppose you set your initial max to 0, but your data file contained all negative numbers?

See where software bugs can come from?

The best way to handle this is to set min and max to some number that is actually in your data file. How will you do this?

How about setting min or max equal to the first number in your data file? It may or may not end up being the eventual minimum or maximum value, but at least it's in the data file, as a reference for starting out the comparisions.

Now you try. Try to complete the code and find the minimum number in the file sample.dat.

Type your code here:

See your results here: