Please help me with my python homework : [Homework Requirement][1]

[This is how the file I am supposed to open look like][2]



Please help me with my python homework.
I am supposed to make some exceptions to my calculations. For example, when I had something like 25/0 it will become an error. How am I suppose to make an exception?


This is my current code:

    import os.path
    fLocation="//Users//Ivan//Desktop//"
    print("Assumed file location is at: ", fLocation)
    fName = input("\nPlease enter a file name with its extension (ex. XXX.txt): ")
    
    fin = open(fLocation + fName, 'r')
    
    fLinesList=fin.readlines()
    
    fin.close()
    print('*' * 50, "\nData items have been read from file:\n\t"
                             + fLocation + fName + '\n')
    
    print('-' * 30, "\nThe list of the lines in the file:\n", fLinesList)
    
    print("\nThere are", len(fLinesList), "lines\n")
    
              # Print file content line by line
    print('\n' + '-' * 30 + '\nFile "' + fName + '" contains:\n')
    print(fLinesList[0].strip())
    print(fLinesList[1].strip())
    print(fLinesList[2].strip())
    print(fLinesList[3].strip())
    print(fLinesList[4].strip())
    print(fLinesList[5].strip())
    
    wordsInLine4 = fLinesList[4].split()
    print('-' * 30, "\nwords in line4  =", wordsInLine4)
    QualityPointsprevious=float(wordsInLine4[6])
    HoursAttemptedprevious=float(wordsInLine4[2])
    GPAprevious=format(QualityPointsprevious/HoursAttemptedprevious,'.2f')
    
    wordsInLine5 = fLinesList[5].split()
    print('-' * 30, "\nwords in line5  =", wordsInLine5)
    
    QualityPointsnow=float(wordsInLine5[6])
    HoursAttemptednow=int(wordsInLine5[2])
    GPAnow=format(QualityPointsnow/HoursAttemptednow,'.2f')
    if (OverallHoursAttempted==0,OverallQualityPoints!=0):
        OverallGPA==-1
    else:
        if (OverallHoursAttempted==0,OverallQualityPoints==0):
            OverallGPA==0
        else:
            if (GPAprevious==-1):
                OverallGPA==-1
    OverallQualityPoints=QualityPointsprevious+QualityPointsnow
    OverallHoursAttempted=HoursAttemptedprevious+HoursAttemptednow
    OverallGPA=format(OverallQualityPoints/OverallHoursAttempted,'.2f')
    QualityPointsprevious=str(QualityPointsprevious)
    HoursAttemptedprevious=str(HoursAttemptedprevious)
    QualityPointsnow=str(QualityPointsnow)
    HoursAttemptednow=str(HoursAttemptednow)
    
    
    
    save_path='C:\\TEMP\\'
    
    text1=fLinesList[0]
    text2=fLinesList[1]
    text3=fLinesList[2]
    text4=fLinesList[3]
    
    text5=fLinesList[4]
    text51=fLinesList[5]
    text6="\n---------------------------"
    text7="\nPrevious GPA:\t"+GPAprevious
    text8="\nCurrent GPA:\t"+GPAnow
    text9="\nOverall GPA:\t"+OverallGPA
    
    text1=str(text1)
    text2=str(text2)
    text3=str(text3)
    text4=str(text4)
    text5=str(text5)
    text51=str(text51)
    text6=str(text6)
    text7=str(text7)
    text8=str(text8)
    text9=str(text9)
    
    wordsInLine0 = fLinesList[0].split()
    print('-' * 30, "\nwords in line0  =", wordsInLine0)
    
    lnameofstudent=wordsInLine0[2]
    fnameofstudent=wordsInLine0[1]
    
    lnameofstudent=str(wordsInLine0[2])
    fnameofstudent=str(wordsInLine0[1])
    
    name=fnameofstudent+" "+lnameofstudent
    
    saveFile=open("C://TEMP//"+name+".txt","w")
    
    saveFile.write(text1)
    saveFile.write(text2)
    saveFile.write(text3)
    saveFile.write(text4)
    saveFile.write(text5)
    saveFile.write(text51)
    saveFile.write(text6)
    saveFile.write(text7)
    saveFile.write(text8)
    saveFile.write(text9)
    saveFile.close()
    
    
      [1]: https://i.stack.imgur.com/zhnJI.png
      [2]: https://i.stack.imgur.com/ND3iR.png