在算后两年的绩点,拿起计算器的时候想说why not Python!
绩点的计算公式如下:
Code如下:
temp = 0
creditsum = 0
while(True):
credit = input('Please enter the credit')
point = input('Please enter the point')
if credit =='done':
break;
else:
a = float(credit)
b = float(point)
temp = a * b + temp
creditsum = creditsum + a
GPA = temp / creditsum
print('GPA is', GPA)
Running Test:
Please enter the credit 1.5 Please enter the point 4
6.0 1.5
Please enter the credit 2.5 Please enter the point 2.7
12.75 4.0
欢迎一起讨论!
如需转载请联系作者并注明出处。