To start things off, this is my assignment(used on Python 3.4):
Here is my code. I think I have a pretty good hang of it:
# import random module
import random
# When doread() returns the maximum integer
# It is printed to the screen.
def main():
# call dowrite() and doread().
dowrite()
doread()
def dowrite():
print ('Write will create 11 random numbers')
print ('The number contained in mynumbers.txt are:')
print('')
# generate random int num that is 5 < x < 13 and print num out
random_int = random.randint(6, 12)
print (random_int)
# use loop to generate num rand ints in range from 10-20 and write ints to mynumbers.txt.
# duplicates acceptable, w/ each int written to one line
myfile = open('mynumbers.txt', 'w')
for count in range(20):
number = random.randint(10, 20)
myfile.write(str(number) + '\n')
def doread():
# open the mynumbers.txt and read all numbers from file using for loop
myfile = open('mynumbers.txt', 'r')
# line = myfile.readline()
# Read each line in the file and display
for line in myfile:
print(line)
# Print each number as it is read and find the largest number.
with open('mynumbers.txt', 'r') as myfile:
largest = max(map(int, myfile))
print('The largest number in the file is: ',largest)
# Close the file and return largest number
myfile.close()
Again, as I said, I think I got the hang of it. Feel free to correct me otherwise, but my main problem is what happens when I press F5:
If someone could help me with this error, I could probably take it from here.



