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,而WhileLeleLeleLeleLeleLoopSituationSituationsItuationsItuationSuationSituationswithUndEtermentersitations。

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

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

pythonisehybridmodeLofCompilation和interpretation:1)thepythoninterpretercompilesourcecececodeintoplatform- interpententbybytecode.2)thepythonvirtualmachine(pvm)thenexecutecutestestestestestesthisbytecode,ballancingEaseofuseEfuseWithPerformance。

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
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境