python计算绩点pta
时间: 2023-10-25 09:19:15 浏览: 142
Python实现两点之间经纬度的计算方法
好的,关于计算绩点和 PTA,你可以参考以下 Python 代码:
```python
# 课程成绩和学分
grades = {"Database": 90, "Web Development": 85, "Data Mining": 93, "Business Intelligence": 88}
credits = {"Database": 3, "Web Development": 4, "Data Mining": 3, "Business Intelligence": 4}
# 计算每门课的绩点和总学分
total_credits = 0
total_gpa = 0
for course, grade in grades.items():
if grade >= 90:
gpa = 4.0
elif grade >= 80:
gpa = 3.0
elif grade >= 70:
gpa = 2.0
elif grade >= 60:
gpa = 1.0
else:
gpa = 0.0
credit = credits[course]
total_gpa += gpa * credit
total_credits += credit
# 计算绩点平均值
gpa_avg = total_gpa / total_credits
print("绩点为:", gpa_avg)
# 计算 PTA得分
pta = gpa_avg * 10 - 30
print("PTA得分为:", pta)
```
希望能对你有所帮助。
阅读全文