Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def filewrite(student_ID, studentName, a1_Weightedmark, a2_Weightedmark, fe_Weightedmark, total_Weightedmark, total):
- outfile = open ("students.txt", 'a')
- outfile.write("Student Student A1 A2 Final Weighted Weighted Total \n ID Name Exam Total with Bonus \n --------------------------------------------------------------------------")
- outfile.write('\n' + str(student_ID))
- outfile.write(str(studentName.rjust(15)))
- outfile.write(format(a1_Weightedmark,'10.1f'))
- outfile.write(format(a2_Weightedmark,'10.1f'))
- outfile.write(format(fe_Weightedmark,'10.1f'))
- outfile.write(format(total_Weightedmark,'10.1f'))
- outfile.write(format(total,'10.1f'))
- outfile.write('\n')
- def main():
- loop = True
- while loop:
- student_ID = int(input("Please enter the student ID:"))
- studentName = (input ("Please enter the student name:"))
- a1_Mark = float(input ("Please enter the marks for Assignment 1:"))
- a1_Weightedmark = a1_Mark * 20/100
- a2_Mark = float(input ("Please enter the marks for Assignment 2:"))
- a2_Weightedmark = a2_Mark * 30/100
- fe_Mark = float(input ("Please enter the marks for the Final Exam:"))
- fe_Weightedmark = fe_Mark * 50/100
- total_Aweightedmarks = a1_Weightedmark + a2_Weightedmark
- total_Weightedmark = total_Aweightedmarks + fe_Weightedmark
- #find the bonus points and add them on to total mark.
- if total_Weightedmark >=50 and total_Weightedmark <=70:
- bonusCalc = total_Weightedmark - 50
- bonus_marks = bonusCalc *10/100
- total = total_Weightedmark + bonus_marks
- elif total_Weightedmark >=70 and total_Weightedmark <=90:
- bonusCalc = total_Weightedmark - 70
- bonus_marks = bonusCalc *15/100 + 2
- total = total_Weightedmark + bonus_marks
- elif total_Weightedmark >=90 and total_Weightedmark <=100:
- bonusCalc = total_Weightedmark - 90
- bonus_marks = bonusCalc *20/100 + 5
- total = total_Weightedmark + bonus_marks
- else:
- bonus_marks = 0
- total = total_Weightedmark
- if total >100:
- total = 100
- print ("Thank You!")
- print ("Weighted mark for Assignment 1:")
- print (a1_Weightedmark)
- print ("Weighted mark for Assessment 2:")
- print (a2_Weightedmark)
- print ("Total weighted mark of the assignments:")
- print (total_Aweightedmarks)
- print ("Weighted mark for the Final Exam is:")
- print (fe_Weightedmark)
- print ("Total weighted mark for the subject:")
- print (total_Weightedmark)
- print ("Bonus points:")
- print (bonus_marks)
- print ("Total mark with bonus:")
- print (total)
- filewrite(student_ID, studentName, a1_Weightedmark, a2_Weightedmark, fe_Weightedmark, total_Weightedmark, total)
- menuInput = str(input("Do you want to enter another student Y/N?"))
- if menuInput == "Y":
- loop = True
- else:
- loop = False
- main()
Add Comment
Please, Sign In to add comment