def nextStudent(): next_student = raw_input('Do you want to enter marks for another student (Y/N)? ') if next_student == "Y": studMarks() elif next_student == "N": mainMenu() nextStudent() def studMarks(): #program to calculate the bonus marks of a student print 45 * "=" print "The Innovation University of Australia (IUA) Grade System " print 45 * "=" print "Please enter all the marks out of 100.\n \n" #enter student details and scores sid = int (input ('Please enter the student ID: ' ) ) name = raw_input ('\nPlease enter the student name: ' ) a1_score = float ( input ( '\nPlease enter the marks for Assignment 1 : ' ) ) a2_score = float ( input ( '\n Please enter the marks for Assignment 2 : ' ) ) final_score = float ( input ( '\n Please enter the marks for the Final Exam : ' ) ) print ('\n \n Thank You!') #if entered wrong score if (a1_score<0 or a1_score>100) and (a2_score<0 or a2_score>100) and ( final_score<0 or final_score>100 ) : print ( '\n invalid assignment score' ) else : # Calculation of weights a1 = (0.2 * a1_score) a2 = (0.3 * a2_score) final = (0.5 * final_score) print ( '\n \n Weighted mark for Assignment 1 : {} ' .format(a1) ) print ( '\n Weighted mark for Assignment 2 : {} ' .format(a2) ) total_assign = a1 + a2 print ( '\n Total Weighted mark of the assignments : {} ' .format(total_assign) ) print ( '\n \n Weighted marks of the Final Exam is : {} ' .format(final) ) total_score = total_assign + final print ( '\n Total Weighted mark for the subject : {} '.format(total_score) ) # Calculation of bonus if 0 <= total_score <= 50: bonus = 0 if 51 <= total_score <= 70: bonus = ((total_score-50)*0.1) if 71 <= total_score <= 90: bonus = (2 + (total_score-70)*0.15) if 91 <= total_score <= 100: bonus = (5 + (total_score-90)*0.2) print ('\n \n Bonus mark : {} ' .format(bonus) ) # Calculation of total marks with bonus mtotal_bonus = bonus + total_score # if total marks with bonus exceed 100 if mtotal_bonus>100: mtotal_bonus = 100 print ('\n Total mark with bonus : {} ' . format(mtotal_bonus) ) def mainMenu(): print 48 * "=" print "Welcome to the AGoS System of IUA \n" print "Please select an option from the following." print "<A>dd details of a student." print "<S>earch student details for a student." print "<Q>uit." print 48 * "=" loop=True while loop: mainMenu() choice = raw_input('Enter your choice [A,S,Q]: ') if choice == "A": studMarks() nextStudent() elif choice == "S": print "search is selected" elif choice == "Q": exit() else: raw_input("Wrong option selection. Enter any key to try again..")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question