- 1
- 0
- 约7.74千字
- 约 8页
- 2026-01-27 发布于北京
- 举报
在下表的每个代码片段旁边,写出打印的内容。如果代码会导致错误,写ERROR并给出简要解释。
_
tweet1=#uoftcs得主SteveCooktweet2=想要便宜的零
食?去@cssuBA2283
Code输出或错误
print(Turingintweet1)True
print(inintweet1andinintweet2)True
print(tweet1[1]+tweet2[‑3])u2
print(tweet1[tweet2[‑1]])ERROR:stringindicesmustbeintegers
print(tweet2[tweet2.find(@):])@cssuofficeinBA2283
问题2.[2marks]
通过添加参数来完成示例函数调用,以获得所示的返回值。(对于每个示例调用,有多个正确,其中
任何一个都可以获得满分。)
defmystery(L):(listofstr)‑str#包含一个以z开头和结尾的字符串
的列表mystery([z])zz#包含三个分别以a和c、d和f、g和
i开头和结尾的字符串的列表。mystery([abc,def,ghi])acdfgi
result=对于L中的每个项:result=
result+项[0]+项[‑1]
返回结果
Question1.[5marks]
Besideeachcodefragmentinthetablebelow,writewhatisprinted.Ifthecodewouldcauseanerror,
writeERRORandgiveabriefexnation.
tweet1=#uoft_csTuringawardwinnerSteveCook
tweet2=Wantcheapsnacks?Visit@cssuofficeinBA2283
CodeOutputorCauseofError
print(Turingintweet1)True
print(inintweet1andinintweet2)True
print(tweet1[1]+tweet2[-3])u2
print(tweet1[tweet2[-1]])ERROR:stringindicesmustbeintegers
print(tweet2[tweet2.find(@):])@cssuofficeinBA2283
Question2.[2marks]
Completetheexamplefunctioncallsbyaddingargumentsthatresultinthereturnvaluesshown.(For
eachexamplecall,thereareseveralcorrectanswers,andprovidinganyoneofthemwillearnfullmarks.)
defmystery(L):
(listofstr)-str
#alistcontainingonestringthatst
您可能关注的文档
最近下载
- 2025年高考数学大题突破培优专题03 立体几何(6大题型)(解析版).docx VIP
- 中石化机泵维修钳工高级复习试题及答案.doc
- 《混凝土结构设计标准》GB T50010-2010(2024年修订).pdf VIP
- 2025年高考数学大题突破培优专题05 圆锥曲线(8大题型)(解析版).docx VIP
- 2025年高考数学大题突破培优专题04 概率与统计(9大题型)(解析版).docx VIP
- (高清版)DB31∕T 1487-2024 国际医疗服务规范.docx VIP
- 2025年漳州市长泰县某国企招聘工作人员若干人备考题库及参考答案详解.docx VIP
- 2023注册安全工程师《化工安全》考点精编 .pdf VIP
- 福建师范大学《高等数学》2019-2020学年第二学学期期末试卷及答案.pdf VIP
- 品牌建设实施方案.doc VIP
原创力文档

文档评论(0)