I'm on the course Python for absolute beginners by Mark Winterbottom, the Modules Section. I've made a follow-along task, and I literally followed every step, but it gives me an error Mark doesn't get. Please, help. Here is a full code (first Module part, and then the Script):
"""
Module for exam predictions.
"""
def get_avg(score_histrory):
"""Takes a list of previous grades and returns average."""
return sum(score_history) / len(score_history)
def predict_score(score_history, min_score=0):
"""Takes a list of previous persentage grades and returns the average."""
score_avg = get_avg(score_history)
if score_avg < min_score:
return min_score
return score_avg
"""
Functions for calculating results.
"""
A_THRESHOLD = 70
B_THRESHOLD = 60
C_THRESHOLD = 50
D_THRESHOLD = 40
E_THRESHOLD = 30
def get_grade(score):
"""Accepts a score and returns a letter version."""
if score >= A_THRESHOLD:
return 'A'
elif score >= B_THRESHOLD:
return 'B'
elif score >= C_THRESHOLD:
return 'C'
elif score >= D_THRESHOLD:
return 'D'
elif score >= E_THRESHOLD:
return 'E'
return 'F'
"""
Srcipt for proccessing students grades.
"""
from grades.predict import predict_score
from grades.results import get_grade
score_history = [5, 10, 10, 2]
predicted_score = predict_score(score_history)
predicted_grade = get_grade(predicted_score)
print(f'The students predicted grade is: {predicted_grade}')
NameError: name 'score_history' is not defined
Thanks a lot. It's my first time asking a question here. Hope for your support.
I think you just have a typo in your code "histrory" and not "history":
def get_avg(score_history):
"""Takes a list of previous grades and returns average."""
return sum(score_history) / len(score_history)