Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Gus Hw Help
# Global variables. Feel free to play around with these # but please return them to their original values before you submit. # HINT: Your code should be using these values, if I change them (and I will) # your output should change accordingly a0_weight = 5 a1_weight = 7 a2_weight = 8 term_tests_weight = 25 exam_weight = 40 exercises_weight = 10 quizzes_weight = 5 a0_max_mark = 25 a1_max_mark = 50 a2_max_mark = 100 term_tests_max_mark = 50 exam_max_mark = 100 exercises_max_mark = 10 quizzes_max_mark = 5 exam_pass_mark = 40 overall_pass_mark = 50 def get_max(component_name): '''(str) -> float Given the name of a course component (component_name), return the maximum mark for that component. This is used to allow the GUI to display the "out of" text beside each input field. REQ: component_name in {'a0', 'a1', 'a2', 'exercises', 'term tests', 'quizzes', 'exam'} >>> get_max('a0') 25 >>> get_max('exam') 100 ''' # DO NOT EDIT THIS FUNCTION. This function exists to allow the GUI access # to some of the global variables. You can safely ignore this function # for the purposes of Ex2. if(component_name == 'a0'): result = a0_max_mark elif(component_name == 'a1'): result = a1_max_mark elif(component_name == 'a2'): result = a2_max_mark elif(component_name == 'exercises'): result = exercises_max_mark elif(component_name == 'term tests'): result = term_tests_max_mark elif(component_name == 'quizzes'): result = quizzes_max_mark else: result = exam_max_mark return result def percentage(raw_mark, max_mark): ''' (float, float) -> float Return the percentage mark on a piece of work that received a mark of raw_mark where the maximum possible mark of max_mark. REQ: raw_mark >=0 REQ: max_mark > 0 REQ: raw_mark <= max_mark >>> percentage(15, 20) 75.0 >>> percentage(4.5, 4.5) 100.0 ''' # divide your parameters and multiply them by 100 and set it to percentage percentage = (raw_mark / max_mark) * 100 # set grade to percentage grade = percentage # grade will return the percentage mark return grade def contribution(raw_mark, max_mark, weight): ''' (float, float, float) -> float Given a piece of work where the student earned raw_mark marks out of a maximum of max_marks marks possible, return the number of marks it contributes to the final course mark if this piece of work is worth weight marks in the course marking scheme. REQ: raw_mark >=0 REQ: max_mark > 0 REQ: weight >= 0 >>> contribution(13.5, 15, 10) 9.0 ''' result = (raw_mark/max_mark)*weight return result def term_work_mark(a0, a1, a2, exercises, quizzes, term_tests): '''(float, float, float, float, float, float) -> float When given the marks for a0, a1, a2, exercises, quizzes and test, will return the term work mark with a maximum of 60. REQ: a0 <= a0_max_mark REQ: a1 <= a1_max_mark REQ: a2 <= a2_max_mark REQ: exercises <= exercises_max_mark REQ: quizzes <= quizzes_max_mark REQ: term_tests <= term_tests_max_mark REQ: term_work_mark <= 60 >>> term_work_mark(25, 50, 100, 10, 5, 50) 60.0 >>> term_work_mark(20, 45, 70, 8, 4, 40) 47.9''' #use the contribution function to get the marks a0_grade = contribution(a0, a0_max_mark, a0_weight) a1_grade = contribution(a1, a1_max_mark, a1_weight) a2_grade = contribution(a2, a2_max_mark, a2_weight) exercises_grade = contribution(exercises, exercises_max_mark, exercises_weight) term_tests_grade = contribution(term_tests, term_tests_max_mark, term_tests_weight) quiz = contribution(quizzes, quizzes_max_mark, quizzes_weight) # add them all up and set it to course_work_mark course_work_mark =(a0_grade + a1_grade + a2_grade + quiz + exercises_grade + term_tests_grade) return course_work_mark def final_mark(a0, a1, a2, exercises, quizzes, term_tests, final_exam): term_work = term_work_mark(a0, a1, a2,exercises, quizzes, term_tests) exam_grade = contribution(final_exam, exam_max_mark, exam_weight) return exam_grade + term_work def is_pass(a0, a1, a2, exercises, quizzes, term_tests, final_exam): final_grade = final_mark(a0, a1, a2, exercises, quizzes, term_tests, final_exam) if (final_grade >= overall_pass_mark & final_exam >= exam_pass_mark): return True else: return False final_g = final_mark(25, 50, 100, 10, 5, 50,100) print(final_g) pass_ = is_pass(10, 21, 12, 2, 1, 15, 23) print(pass_)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Mounesh
Shabnam_ticket
Lambda
Dictionary comprehension - convert to lowercase
python permutations
Lambda
project euler 16
bacs_class
PyClassInit
tree generator
Please log in to post a comment.