1 以下代码的输出结果为:
print(round(-3.6))
A.-4
B.-4.0
C.-3
D. -3.0
2 以下代码的输出结果为(Python3.6及以上):
dic={ 'a':1,'b':4,'c':9,'xy':13} print(dic.popitem())
A.(‘a’:1,‘b’:4,‘c’:9)
B.(‘c’:9,‘xy’:13)
C.(‘a’,13)
D.(‘xy’,13)
3 以下代码的输出结果为:
adict = dict.fromkeys(['key1', 'key2'], []) adict['key1'].append(123) adict['key1'] = 456 print(adict['key2'])
A.报错
B.[]
C.[123]
D. 456
4 以下代码的输出结果为:
print([1, 2] == [(1), (2)]) print([1, 2] == [(1,), (2,)])
A.True True
B.True False
C.False True
D.False False
5 以下代码的输出结果为:
print('hi') if 3 > 4 else print('bye')
A.报错
B.hi
C.bye
D.hi bye
6 以下代码的输出结果为:
num = 6 if True == 1.0 else 8 print(num)
A.报错
B.6
C.8
D.True
7 以下代码的输出结果为:
for i in range(5): pass print(i)
A.报错
B.None
C.4
D.5
8 以下代码的输出结果为:
alist = [1, 2, 3] blist = [i ** 2 for i in alist] print(i)
A.报错
B.None
C.3
D.9
9 执行完以下代码后,blist的值为:
alist = [1, 2, 3] blist = [print(i+1) for i in alist]
A.[1,2,3]
B.[2,3,4]
C.[None,None,None]
D.[]
10 关于以下代码的描述正确的是:
print({ 'a',[1,2]})
A.不会报错
B.如果把[1,2]改成元组不会报错
C.如果把[1,2]改成集合不会报错
D.如果把[1,2]改成集合会输出{‘a’,1,2}
答案:A D C B C B C A C B
以上是Python简单的测试题有哪些的详细内容。更多信息请关注PHP中文网其他相关文章!

Python是解释型语言,但也包含编译过程。1)Python代码先编译成字节码。2)字节码由Python虚拟机解释执行。3)这种混合机制使Python既灵活又高效,但执行速度不如完全编译型语言。

useeAforloopWheniteratingOveraseQuenceOrforAspecificnumberoftimes; useAwhiLeLoopWhenconTinuingUntilAcIntiment.ForloopSareIdeAlforkNownsences,而WhileLeleLeleLeleLoopSituationSituationSituationsItuationSuationSituationswithUndEtermentersitations。

pythonloopscanleadtoerrorslikeinfiniteloops,modifyingListsDuringteritation,逐个偏置,零indexingissues,andnestedloopineflinefficiencies

forloopsareadvantageousforknowniterations and sequests,供应模拟性和可读性;而LileLoopSareIdealFordyNamicConcitionSandunknowniterations,提供ControloperRoverTermination.1)forloopsareperfectForeTectForeTerToratingOrtratingRiteratingOrtratingRitterlistlistslists,callings conspass,calplace,cal,ofstrings ofstrings,orstrings,orstrings,orstrings ofcces

pythonisehybridmodelofcompilationand interpretation:1)thepythoninterspretercompilesourcececodeintoplatform- interpententbybytecode.2)thepytythonvirtualmachine(pvm)thenexecuteCutestestestesteSteSteSteSteSteSthisByTecode,BelancingEaseofuseWithPerformance。

pythonisbothinterpretedAndCompiled.1)它的compiledTobyTecodeForportabilityAcrosplatforms.2)bytecodeisthenInterpreted,允许fordingfordforderynamictynamictymictymictymictyandrapiddefupment,尽管Ititmaybeslowerthananeflowerthanancompiledcompiledlanguages。

在您的知识之际,而foroopsareideal insinAdvance中,而WhileLoopSareBetterForsituations则youneedtoloopuntilaconditionismet

ForboopSareSusedwhenthentheneMberofiterationsiskNownInAdvance,而WhileLoopSareSareDestrationsDepportonAcondition.1)ForloopSareIdealForiteratingOverSequencesLikelistSorarrays.2)whileLeleLooleSuitableApeableableableableableableforscenarioscenarioswhereTheLeTheLeTheLeTeLoopContinusunuesuntilaspecificiccificcificCondond


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

Dreamweaver CS6
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器