2025年6月电子学会青少年软件编程(Python五级)等级考试试卷
客观题
五级
2025
2025-07-24 17:32:38
37次
一、单选题
假设有一个列表 sports = ["football", "run", "basketball"],需要向这个列表中添加一个新的元素 "pingpang"。下列哪个选项里的代码执行最快?( )
sports = ["football", "run", "basketball"]
____________
| A. sports = sports + ["pingpang"] |
B. sports[3] = "pingpang" |
| C. sports.append("pingpang") |
D. sports.insert(0, "pingpang") |
【知识点】 电子学会Python五级
有两个列表,一个包含学生的名字 names = ["李明", "王华", "张亮"],另一个包含他们的年龄 ages = [12, 10, 13]。使用 zip() 函数将这两个列表合并为一个包含元组的列表,每个元组包含一个名字和对应的年龄。在下列4个选项中,哪个选项中的代码补全在①处后,可以正确的实现此功能?( )
names = ["李明", "王华", "张亮"]
ages = [12, 10, 13]
merged_list = ①
print(merged_list)
| A. list(zip(names, ages)) |
B. zip(names, ages) |
| C. list(merge(names, ages)) |
D. list(zip(ages, names)) |
【知识点】 电子学会Python五级
已知选修课学生名单 course1 = {"张三", "李四", "王五"}, course2 = {"李四", "赵六", "王五"}。要找出同时选修两门课的学生,应使用的推导式是?( )
| A. {x for x in course1 if x in course2} |
B. [x for x in course1 and course2] |
| C. {x for x in course1 or course2} |
D. {x for x in course1 if x not in course2} |
【知识点】 电子学会Python五级
小明的学习小组需要整理数学考试成绩,将高于等于80分的记录标记为"A",60-79分标记为"B",其余标记为"C"。已知成绩列表为 scores = [75, 92, 58, 84, 65],以下哪种推导式能正确生成等级列表? ( )
| A. ["A" for x in scores if x >=80] + ["B" for x in scores if 60<=x<80] + ["C" for x in scores if x<60] |
B. ["A" if x >= 80 else "B" if x >= 60 else "C" for x in scores] |
| C. [x >=80 ? "A" : x >=60 ? "B" : "C" for x in scores] |
D. { "A" if x >=80 else "B" if x >=60 else "C" for x in scores } |
【知识点】 电子学会Python五级
韩信带1500名士兵打仗,战死四五百人,剩下的士兵排队:站3人一排,多出2人;站5人一排,多出4人;站7人一排,多出6人。下列代码中不能正确计算剩余士兵人数的是? ( )
A.for x in range(998,1100,3): if x%5==4 and x%7==6: print(x) |
B.for x in range(1100,1000,-3): if x%5==4 and x%7==6: print(x) |
C.for x in range(1000,1100,3): if x%5==4 and x%7==6: print(x) |
D.for x in range(1000,1100,1): if x%3==2 and x%5==4 and x%7==6: print(x) |
【知识点】 电子学会Python五级
班级组织户外活动,老师要统计带水杯的同学名单。已知学生信息列表为:
students = [{"name": "小明", "has_cup": True}, {"name": "小红", "has_cup": False}, {"name": "小刚", "has_cup": True}],正确的推导式是?( )
| A. [student["name"] for student in students if has_cup] |
B. [name for student in students where student.has_cup] |
| C. [student["name"] for student in students if student["has_cup"]] |
D. [student.name for student in students when student.has_cup] |
【知识点】 电子学会Python五级
期中考试阅卷系统导出的成绩是按字典数据保存的,陈老师想提取字典中所有学生的分数,并转换为列表。
下列哪个选项中的代码能帮陈老师实现这个想法呢? ( )
scores = {'敖闰': 90, '哪吒': 85, '申公豹': 88}
_________________
| A. score_list = list(scores) |
B. score_list = list(scores.values()) |
| C. score_list = list(scores.items()) |
D. score_list = list(scores.keys()) |
【知识点】 电子学会Python五级
