我正在尝试将下面图片中的等级类别进行映射。然后,我希望能够调用一个函数,将一个等级转换为相同格式的等效等级。例如:
def convert(num, letter, gpa):
"""Converts a grade into an equivalent grade. The desired output will be
specified by -1 and the grade format not to be involved in the conversion
will be specified by None. When converting to GPA, the minimum of the gpa
range will be returned."""
>>> convert(83, None, -1)
>>> 'A-'
>>>convert(-1, 'B+', None)
>>>77
我考虑为等价性创建三个并列列表,然后函数最终会使用一堆if语句。最佳方法是什么?