#consolidation - week 8

import csv

with open('studentRecords.txt', 'r') as f:
    reader = csv.reader(f)
    records = list(reader)

def optionA():
    name=input("\nEnter the name of the student: ")
    for record in records:
        if record[0] == name:
            total=int(record[2])+int(record[3])+int(record[4])+int(record[5])
            print(record[0],"Total:",total)

def optionB():
    for record in records:
        if record[1] == "GCSE":
            total=int(record[2])+int(record[3])+int(record[4])+int(record[5])
            print(record[0],total)

def optionC():
    total=0
    count=0
    for record in records:
        if record[1] == "BTEC":
            subtotal=int(record[2])+int(record[3])+int(record[4])+int(record[5])
            total+=subtotal
            count+=1
    average=total/count
    print("BTEC average mark:",average)

repeat=True
while repeat==True:
    print("""\nOption A	Search for a student
Option B	Display GCSE students
Option C	Display average total mark for BTEC students""")
 
    choice=input("Enter A, B or C:\n").lower()
    if choice=="a":
        optionA()
    elif choice=="b":
        optionB()
    elif choice=="c":
        optionC()






