sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

21 lines
787 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 运行程序前, 请务必前往本课包【课程说明】处,下载课程素材,完成配置
import csv
# 读取CSV文件并计算平均分进行排序
def process(filename):
with open(filename, 'r') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
# 提取学生姓名和成绩,并转换成整数
name = row['姓名']
landmark_score = int(row['地标挑战赛成绩'])
history_score = int(row['历史挑战赛成绩'])
life_score = int(row['生活常识挑战赛成绩'])
# 计算总分
total_score = landmark_score + history_score + life_score
print(total_score) # print语句仅测试使用后面可以删掉
process('scores.csv')