题库首页 › 青少年软件编程(Python) › 题目 19373

学生信息处理编写一个Python程序,实现以下功能:(1)创建一个名为"students.txt"的文件;(2)向文件中写入3个学生的信息(姓名、年龄、成绩),每行一个学生;(3)读取文件内容并打印出来;(4)计算并打印学生的平均成绩,保留两位小数。程序:with open('students.txt', ' ① ') as f:

F:write("王五 19 78n")print("学生信息:")with open('students.txt', ' ② ') as f:students = f. ③ ()total_score = 0count = 0for student in students:print( ④ .strip())_, _, score = student.split()total_score += int(score)count += 1average = total_score / countprint(f"学生的平均成绩为:{average: ⑤ }")

正确答案:补全答案(Python学生信息):①w ②r ③readlines ④student ⑤.2f。核心:文件读写平均分。

试卷来源:202603 青少年软件编程等级考试Python六级真题

本卷相关题目

在线做题 同科目题库