<jupyter_start><jupyter_text>What do I need to get on the exam?This is common question. Knowing my current mark and the "weighting" of the final exam, what mark would I need to get in order to achieve my desired final grade? We'll leave out discussions of assessment practices.Basically a final grade is **coursework mark** times **weighting** plus **exam mark** times **weighting**. We can calculate a final grade if the exam is 30% using $G_{final} = (M_{exam} \times 0.3) + (M_{course} \times 0.7)$ where $M_{exam}$ is the mark achieved on the exam and $M_{course}$ is the mark achieved in the coursework.Manipulating that to solve for the exam mark, we get $M_{exam} = \frac{G_{final} - (M_{course} \times 0.7)}{0.3}$. Or more generally $M_{exam} = \frac{G_{final} - (M_{course} \times W_{course})}{W_{exam}}$ .<jupyter_code>course_mark = 75
desired_final_mark = 80
exam_weighting = 0.3 # 30% is 0.3

exam_mark = (desired_final_mark - (course_mark * (1-exam_weighting))) / exam_weighting
print(exam_mark)<jupyter_output>91.66666666666667<jupyter_text>That means to get 80% as a final mark when your course mark is 75% (and the final exam is weighted at 30%) you would need to get about 92% on the exam.Next let's define a function for that calculation, and we'll use that function to for some interactivity.<jupyter_code>def calculate_exam_mark(course_mark, desired_final_mark, exam_weighting):
    exam_mark = (desired_final_mark - (course_mark * (1-exam_weighting))) / exam_weighting
    return exam_mark
print('Defined the function calculate_exam_mark')
course_mark = int(input('Current course mark: '))
desired_final_mark = int(input('Desired final mark: '))
exam_weighting = int(input('Weighting of the exam as a percent (e.g. 30): '))

if 0 < course_mark < 101 and 0 < desired_final_mark < 101 and 0 < exam_weighting < 101:
    if exam_weighting > 1: # if it was input as requested then divide by 100, otherwise leave it
        exam_weighting = exam_weighting / 100
    exam_mark = calculate_exam_mark(course_mark, desired_final_mark, exam_weighting)
    print('You would need to get '+'{:.0f}'.format(exam_mark)
          +'% on the final exam to achieve '+'{:.0f}'.format(desired_final_mark)+'%.')
else:
    print(course_mark, desired_final_mark, exam_weighting)
    print('Please enter numbers between 0 and 100')<jupyter_output>Current course mark: 80
Desired final mark: 90
Weighting of the exam as a percent (e.g. 30): 30
You would need to get 113% on the final exam to achieve 90%.<jupyter_text>It might also be interesting to find your maximum and minimum possible grades given your course mark and exam weighting.<jupyter_code>course_mark = int(input('Current course mark: '))
exam_weighting = int(input('Weighting of the exam as a percent (e.g. 30): '))
if exam_weighting > 1:
    exam_weighting = exam_weighting / 100
minimum_grade = course_mark * (1-exam_weighting)
maximum_grade = minimum_grade + 100 * exam_weighting
print('Zero on the final will get you '+'{:.0f}'.format(minimum_grade)
      +'% and 100% on the final will get you '+'{:.0f}'.format(maximum_grade)+'%.')<jupyter_output>Current course mark: 80
Weighting of the exam as a percent (e.g. 30): 30
Zero on the final will get you 56% and 100% on the final will get you 86%.<jupyter_text>And let's create a graph to represent potential final grades based on your course mark and the exam weighting. Change the numbers in the variables below before you run the cell.<jupyter_code>course_mark = 80
exam_weighting = 0.3

import plotly.graph_objects as go
import numpy as np

exam_mark = np.linspace(0, 100, 100)
final_grade = exam_mark * exam_weighting + course_mark * (1-exam_weighting)
final_grade2 = exam_mark * exam_weighting + 50 * (1-exam_weighting)
final_grade3 = exam_mark * exam_weighting + 100 * (1-exam_weighting)

fig = go.Figure(data=[
    go.Scatter(x=exam_mark, y=final_grade, mode='lines', name='Coursework '+str(course_mark)+'%'),
    go.Scatter(x=exam_mark, y=final_grade2, mode='lines', name='Coursework 50%'),
    go.Scatter(x=exam_mark, y=final_grade3, mode='lines', name='Coursework 100%')
])
fig.update_layout(title='Final Grades When Course Mark is '+str(course_mark)
                  +'% and Exam Weighting is '+str(exam_weighting*100)+'%',
                  xaxis_title='Exam Mark', yaxis_title='Final Grade')
fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10988758889653591, 'fraction_numerical': 0.033264510208763476, 'mean_word_length': 4.972602739726027, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '202033', 'license': 'Unlicense', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1412, 'n_words': 487, 'path': 'exam-mark-goal.ipynb', 'repo_name': 'misterhay/Interesting-Problems', 'size': '4359'}