Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1.  
  2. 11.10 Lab Exam 2 - Professor Joy
  3. This section has been set as optional by your instructor.
  4.  
  5. You're helping Professor Joy to calculate the grades for his course. The way his course is organised, students take two exams and their final grade is the weighted average of the two scores, where their lowest score weights 70% and their highest score 30%.
  6.  
  7. To accomplish this, you are going to need to do the following:
  8.  
  9. (1) Build the Student named tuple with the following attributes:
  10.  
  11. name (string)
  12. exam1 (float)
  13. exam2 (float)
  14.  
  15. (2) Write a function create_student, which will ask the user to input a single student's name, exam 1 score, and exam 2 score. The function will then create a named tuple with this information and return it.
  16.  
  17. (3) Write a function create_class, which takes as input an integer n, calls create_student n times and returns a list with the n students created.
  18.  
  19. (4) Write a function calculate_score, which takes a single Student named tuple as input, and returns the final score, where their lowest grade is weighted 70% and their highest grade is weighted 30%.
  20.  
  21. (5) Print the value returned by calculate_score for each student created in main. Round each score to two decimal places (using round(value, 2)).
  22.  
  23. Example 1: if the input is:
  24.  
  25. 1
  26. Student 1
  27. 10
  28. 0
  29.  
  30. then the output is:
  31.  
  32. 3.0
  33.  
  34. Example 2: if the input is:
  35.  
  36. 2
  37. Student 1
  38. 10
  39. 0
  40. Student 2
  41. 7
  42. 8
  43.  
  44. then the output is:
  45.  
  46. 3.0
  47. 7.3
  48.  
  49. Example 3: if the input is:
  50.  
  51. 0
  52.  
  53. then the output is:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement