【发布时间】:2021-01-13 15:42:54
【问题描述】:
目前我的代码是:
def GPAcalc(grade, weighted):
grade = grade.lower()
dictionary = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}
if weighted == 1 and grade in dictionary:
return "Your GPA score is: "+str(dictionary[grade] + 1)
elif weighted == 0 and grade in dictionary:
return "Your GPA score is: "+str(dictionary[grade])
else:
return "Invalid"
def GPAav():
grade = GPAcalc()
for i in range(0,cl):
grad= GPAcalc(grade,dictionary)
total = grade + total
print(total/cl)
cl = int(input("How many Classes are you taking? "))
for i in range(0,cl):
print(GPAcalc(input("Enter your letter Grade: "), int(input("Is it weighted?(1= yes, 0= no) "))))
GPAav()
我必须从其余代码中找到十进制形式的平均 GPA 并将其输出。我将如何从 GPAcalc 中获取值并在 GPAav 中使用它,以便将其平均化?
【问题讨论】:
-
你想要的和你现在的代码有什么区别?
标签: python