编程要求:
本关的编程任务是补全checkWork.py
文件中的部分代码,具体要求如下:
-
填入循环遍历
studentname
列表的代码; -
当遍历到缺席学生时,填入
continue
语句跳过此次循环。
本关涉及的代码文件checkWork.py
的代码框架如下:
absencenum = int(input())
studentname = []
inputlist = input()
for i in inputlist.split(','):
result = i
studentname.append(result)
count = 0
# 请在此添加代码,填入循环遍历studentname列表的代码
########## Begin ##########
########## End ##########
count += 1
if(count == absencenum):
# 请在下面填入continue语句
########## Begin ##########
########## End ##########
print(student,"的试卷已阅")
测试说明:
本文的测试文件是checkWork.py
,具体测试过程如下:
-
平台自动编译生成
checkWork.exe
; -
平台运行
checkWork.exe
,并以标准输入方式提供测试输入; -
平台获取
checkWork.exe
输出,并将其输出与预期输出对比。如果一致则测试通过,否则测试失败。
以下是平台对src/step2/checkWork.py
的样例测试集: 测试输入:
2
zhangsan,lisi,wangwu,zhaoliu,qianqi
预期输出:
zhangsan 的试卷已阅
wangwu 的试卷已阅
zhaoliu 的试卷已阅
qianqi 的试卷已阅
答案:
absencenum = int(input())
studentname = []
inputlist = input()
for i in inputlist.split(','):
result = i
studentname.append(result)
count = 0
#请在此添加代码,填入循环遍历studentname列表的代码
#********** Begin *********#
for student in studentname:
#********** End **********#
count += 1
if(count == absencenum):
#在下面填入continue语句
#********** Begin *********#
continue
#********** End **********#
print(student,"的试卷已阅")