Skip to content

Instantly share code, notes, and snippets.

@HoughIO
Last active August 29, 2015 14:09
Show Gist options
  • Save HoughIO/b05fb1fe98e21160e48a to your computer and use it in GitHub Desktop.
Save HoughIO/b05fb1fe98e21160e48a to your computer and use it in GitHub Desktop.
no idea
## Individual Lab 14
def main():
mydata = input("Filename? ")
try:
infile = open(mydata, "r")
except:
print("Can't open file")
return
print('File opened')
ctr = 0
total = 0
for line in infile:
avg = process(line)
total += avg
print(avg)
ctr +=1
print("\nAverage over all students =", end=" ")
if total != 0:
print(total / ctr)
else:
print(0)
infile.close()
def process (line):
lst = line.split()
# first name, last name, 5 grades
tot = 0
print(lst[0], lst[1], end=" ")
for i in range(2, 7):
gr = int(lst[i])
tot += gr
return tot/5
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment