How to avoid error: name 'score history' is not defined in modules section in Python for absolute beginners by Mark Winerbottom

How to avoid error: name 'score history' is not defined in modules section in Python for absolute beginners by Mark Winerbottom

我正在学习模块部分 Mark Winterbottom 为绝对初学者开设的课程 Python。 我已经完成了一项后续任务,并且我确实遵循了每一步,但它给了我一个 Mark 没有得到的错误。 请帮忙。 这是完整的代码(第一个模块部分,然后是脚本):

"""
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: 名称 'score_history' 未定义

非常感谢。这是我第一次在这里提问。希望大家多多支持

我认为您的代码“history”而不是“history”中有一个拼写错误:

def get_avg(score_history):
"""Takes a list of previous grades and returns average."""
    return sum(score_history) / len(score_history)