Exam score using a function
Q1. Enter in this code and run it:
1 def grade(mark):
2 '''
3 This program decides how well you have done in an exam.
4 It needs one integer.
5 It returns one string, saying how well you did.
6 '''
7 if mark > 70:
8 return 'Pass with distinction'
9 elif mark > 60:
10 return 'Pass with merit'
11 elif mark > 50:
12 return 'Pass'
13 else:
14 return 'Fail'
15
16 yourScore = int(input("Please enter your score >>> ", end=" "))
17 print(grade(yourScore))
18 input("Press <ENTER> to quit")
Q2. Describe how this program works.
Q3. Change the program so you get a distinction if you get 80 or more.
Q4. Describe what tests you should do to fully test getting a distinction works as intended.
Q5. Why should you include lines 13 and 14? What would be the effect of leaving them out?
Q6. How many parameters does the function need to work?
Q7. How many parameters does the function return?
Q8. Modify your program so that people with a score of 95% or more are told they will get a prize.
Q9. Insert some escape sequences to space out the output.
Q10. Modify the program so that the user can keep entering scores and finding out what grading they got without having to restart the program. The program should ask the user if they want another go after they have entered in a score.