Again suppose that sample.dat contains a list of amounts spent by patrons during lunch at a retaurant. Let's see if we can tell the owner what his maximum sale amount was. In other words, let's find the maximum number in the file sample.dat.
We'll need a loop to be able to examine each number in the file, and we'll apply some coding logic to try and figure what the maximum value is in the data file.
Now you try. Try to complete the code and find the maximum number in the file sample.dat.
Type your code here:
See your results here:
The code won't run as is. Note the usual file-open and looping bit we've covered, that will run through all data points in the file. We've left two challenges for you: 1) What should max be set to initially and 2) What should the if statement be?
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Does your code work? Want to run it on your iPhone?
Here's your code:
Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
Then click the "Use on iPhone" button that you'll see.