See this link on functions http://www.tutorialspoint.com/python/python_functions.htm You should also have a function_1 that will input the name and grade until told to stop. It would also receive the "data" list and append to it. If the length of "data" is zero, then option 2 has not been selected. You can either print an error message or call function_2 from function_1 to read the data. It is a good habit to include some useful info about what the function does with every function call for future reference.
def function_2():
""" get the file name, open and read the file, and return the data
"""
fname = input("What is the file name?")
file1 = open(fname, "r")
data = file1.readlines()
file1.close()
return data
def function_3(data):
""" process the data by calculating the mean
"""
for rec in data:
print rec
def main():
data=""
choice = input("Please enter the number for your choice or press <enter> to quit\n\n1.) Add a student to File\n2.) Display course info\n3.) Display course stats.")
if choice == '1':
function_1(data)
elif choice == '2':
data=function_2() #should open file to read file
print data
elif choice == '3':
function_3(data) #display results from arithmetic mean and range for the course
else:
print "Enter 1, 2, or 3 only"
file1 = open(filename1,"a")
file1.write(myInfo + "," ",\n" )
file1.close()
if __name__ == '__main__':
main()