![PYTHON測試題_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd1.gif)
![PYTHON測試題_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd2.gif)
![PYTHON測試題_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd3.gif)
![PYTHON測試題_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd4.gif)
![PYTHON測試題_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd/7489cf50-8e0a-48ff-bb90-4bd2cb01c2cd5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、I.what does the following code do?(B)def a(b, c, d): passA.defines a list and initializes itB.defi nes a fun cti on, which does nothingC.defi nes a fun cti on, which passes its parameters throughD.defi nes an empty class2.what gets prin ted? Assu ming pyth on vers ion 2.xA) print type(1/2)A.vtype in
2、tB.vtype nu mberC.vtype floatD.vtype doubleE.vtype tuple3 what is the output of the following code?(E)print type(1,2)A.type tupleB.C.type setD.E.4.what gets prin ted? (C)def f(): pass print type(f()A.type functionB.C.type No neTypeD.E.5._what_should_the_below_code_pri nt?A) print type(1J)A.B.C.D.E.6
3、.what is the output of the following code?(D) print type(lambda:N one)A.vtype Non eTypeB.vtype tupleC.vtype typeD.type functionE.vtype bool7. what is the output of the below program?。)a = 1,2,3,No ne,(),print len(a)A.s yn tax errorB.4C.5D.6E.78.what gets prin ted? Assu ming pyth on vers ion 3.xC) pr
4、int (type(1/2)A.B.type nu mberC.type floatD.E.9. What gets prin ted?C)d=lambda p: p * 2t = lambda p: p * 3x : =2x : =d(x)x : =t(x)x : =d(x)pr nt xA.7B.12C.24D.36E.4810.What gets prin ted?A) x = 4.5y = 2 print x/yA.2.0B.2.25C.9.0D.20.25E.2111.What gets prin ted?C) nums = set(1,1,2,3,3,3,4) print len(
5、nu ms)A.1B.2C.4D.5E.712.What gets prin ted?A) x = Truey = False z = Falseif x or y and z:prin t yeselse:print noA.yesB.noC.fails to compile13.What gets prin ted?C) x = Truey = False z = Falseif not x or y:print 1elif not x or not y and z: print 2elif not x or y or not y and x: print 3else:print 4A.1
6、B.2C.3D.414.If PYTHONPATH is set in the environment, which directories are searchedfor modules?(D)A)PYTHONPATH directoryB)current directoryC)home directoryD)in stallati on depe ndent default pathA.A onlyB.A and DC.A, B, and CD.A, B, and DE.A, B, C, and D15.In python 2.6 or earlier, the code will pri
7、nt error type 1 if accessSecureSystem raises an excepti onof either AccessError type or SecurityError type() try:accessSecureSystem()except AccessError, SecurityError:prin t error type 1con ti nu eWork()A.trueB.false16.The following code will successfully print the days and then the monthsB) daysOfW
8、eek = Monday,Tuesday,Wed nesday, Thursday, Friday, Saturday, Su ndayJa n, Feb, Mar, Apr, May, Ju n, Jul, Aug, Sep, Oct, Nov, Decprin t DAYS: %s, MONTHS %s % (daysOfWeek, mon ths)A.trueB.false17.Assu ming pyth on 2.6 what gets prin ted?A) f = Nonefor i in range (5):with ope n(data.txt, w) as f: if i
9、2:breakprint f.closedmon ths =A.TrueB.FalseC.N one18.What gets prin ted?C) coun ter = 1def doLotsOfStuff(): global coun ter for i in (1,2, 3):coun ter += 1doLotsOfStuff()print coun terA.1B.3C.4D.7E.none of the above19.What gets prin ted?C) print rn woowA.new line then the string: woowB.the text exac
10、tly like this: rn woowC.the text like exactly like this: n woowD.the letter r and then newline then the text: woowE.the letter r then the text like this: nwoow20.What gets prin ted?B) prin t hello worldA.on one line the text: hello worldB.on one line the text: helloworldC.hello on one line and world
11、 on the n ext lineD.syntax error, this python program will not run21.What gets prin ted?E) prin t x48x49!A.x48x49!B.4849C.4849!D.4849!E.HI!22.What gets prin ted?D) prin t 0 xA + OxaA.OxA + 0 xaB.OxA 0 xaC.14D.20E.0 x2023.What gets prin ted?E) class pare nt:def _init_(self, param): self.v1 = paramcla
12、ss child(pare nt):def _init_(self, param): self.v2 = paramobj = child(11)prin t %d %d % (obj.vl, obj.v2)A.No ne NoneB.N one 11C.11 NoneD.11 11E.Error is gen erated by program24.What gets prin ted?E) kvps = user,bill, password,hillaryprint kvpspasswordA.userB.billC.passwordD.hillaryE.Nothi ng. Pyth o
13、n syn tax error25.What gets prin ted?B)66% on 1871 times askedclassAccount:def _init_(self, id): self.id = id id = 66649!acc = Accou nt(123) print acc.idA.No neB.123C.666D.SyntaxError, this program will not run26.What gets prin ted?C) n ame = snow storm prin t %s % name6:8A.stB.stoC.toD.torE.S yn ta
14、x Error27.What gets prin ted?D) n ame = snow stormname5 = Xprint n ameA.s now stormB.sno wXstormC.s now XtormD.ERROR, this code will n ot ru n28.Which numbers are prin ted?C)for i inran ge(2):print ifor i in ran ge(4,6): print iA.2, 4, 6B.O, 1,2, 4, 5, 6C.O, 1,4, 5D.0, 1,4, 5, 6, 7, 8, 9E.1,2, 4, 5,
15、 649!29.What seque nee of nu mbers is prin ted values = 1,2, 1,3 nums = set(values)def eheekit (nu m):if num in nu ms:return Trueelse:return Falsefor i in filter(eheekit, values):print iA.1 2 3B.1 2 1 3C.1 2 1 3 1 2 1 3D.1 1 1 1 2 2 3 3E.S yn tax Error30.What seque nee of nu mbers is prin ted?E) val
16、ues = 2, 3, 2, 4def my_tra nsformatio n(nu m):return num * 2for i inmap(my_tra nsformatio n, values):print iA.2 3 2 4B.4 6 4 8C.1 1.5 1 2D.1 1 1 2E.4 9 4 1631.What numbers get pri ntedC) import pickleclass acco unt:def _init_(self, id, bala nee): self.id = idself.bala nee = bala nee def deposit(self
17、, amoun t):self.bala nee += amount def withdraw(self, amoun t): self.bala nee -= amountmyac = accou nt(123, 100) myac.deposit(800) myac.withdraw(500)fd = ope n( archive, w) pickle.dump( myac, fd) fd.close()49!myac.deposit(200) print myac.bala neefd = ope n( archive, r) myac = pickle .lo ad( fd ) fd.
18、close()print myac.bala neeA.500 300B.500 500C.600 400D.600 600E.300 50032.What gets prin ted by the code sni ppet below?B) import mathprint math.floor(5.5)A.5B.5.0C.5.5D.6E.6.033.What gets printed by the code below?() class Pers on:def _init_(self, id): self.id = idobama = Perso n(100)obama._dict_ag
19、e = 49print obama.age + len (obama.dict)A.1B.2C.49D.50E.5134.What gets prin ted?E) x = foo y = 2 print x + yA.foo49!B.foo fooC.foo 2D.2E.A n excepti on is throw n35.What gets prin ted?E) def simpleF unction():This is a cool simple function that returns 1 return 1print simpleF unction. doc 10:14A.sim
20、pleF un ctio nB.simpleC.fu ncD.fun ti onE.cool36.What does the code below do?C) sys.path.appe nd(/root/mods)A.Cha nges the locati on that the pyth on executable is run fromB.Cha nges the curre nt worki ng directoryC.Adds a new directory to seach for pytho n modules that are importedD.Removes all dir
21、ectories for modsE.Cha nges the locati on where sub-processes are searched for after they are laun ched37.What gets prin ted?C) import resum = 0 pattern = backif re.match(pattern, backup.txt):sum += 1if re.match(pattern, text.back):sum += 2if re.search(pattern, backup.txt):sum += 4if re.search(patte
22、rn, text.back):sum += 8print sumA.3B.749!C.13D.14E.1538.Which of the following print statements will print all the names in the list on a seperate lin eA) names = Ramesh, Rajesh, Roger, Iva n, NicoA.pri nt n.jo in(n ames)B.pri nt n ames.jo in (n)C.pri nt n ames.c on cate nate(n)D.pri nt n ames.appe
23、nd(n)E.pri nt n ames.jo in (%sn, n ames)39.True or false? Code inden tati on must be 4 spaces whe n creat ing a code blocB?( if error:# four spaces of indent are used to create the block prin t %s % msgA.TrueB.False40.Assu ming the file name for the code below is /usr/lib/pytho n/pers on .py and the
24、 program is runas:pytho n /usr/lib/pyth on/pers on .pyWhat gets prin ted?D) class Pers on:def _init_(self): passdef getAge(self): print _n amep = Pers on() p.getAge()A.Pers onB.getAgeC.usr.lib.pytho n.pers onD._main_E.A n excepti on is throw n41.What gets prin tedB) foo = print type(foo)A.setB.dictC
25、.list49!D.tupleE.object42.What gets prin ted?C) foo = (3, 4, 5) print type(foo)A.i ntB.listC.tupleD.dictE.set43.What gets prin ted?D) coun try_co un ter = def add on e(co un try):if country in coun try_c oun ter:coun try_co un terco un try += 1else:coun try_co un terco un try = 1add on e(Chi na)add
26、on e(Japa n)add on e(chi na)print len(coun try c oun ter)A.0B.1C.2D.3E.444.What gets prin ted?D) con fusi on = con fusi on1 = 1con fusio n1 = 2con fusi on1 += 1sum = 0for k in con fusi on:sum += con fusi onk49!print sumA.1B.2C.3D.4E.545.What gets prin ted?C) con fusi on = con fusi on1 = 1con fusio n
27、1 = 2con fusio n1.0 = 4sum = 0for k in con fusi on:sum += con fusi onkprint sumA.2B.4C.6D.7E.A n excepti on is throw n46.What gets prin ted?E) boxes = jars = crates = boxescereal = 1 boxesca ndy = 2 jarsho ney = 4 cratesboxes = boxes cratesjars = jarsprint len( cratesboxes)A.1B.2C.4D.7E.A n excepti
28、on is throw n47. What gets prin ted?E)nu mberGames = 49!nu mberGames(1,2,4)=8numberGames(4,2,1)=10numberGames(1,2)=12sum = 0for k in nu mberGames:sum += nu mberGameskprint len(nu mberGames) + sumA.8B.12C.24D.30E.3348.What gets prin ted?A) foo = 1:1, 2:2, 3:3 foo = print len(foo)A.0B.1C.2D.3E.An exce
29、ption is thrown49.What gets prin ted?B) foo = 1:1, 2:2, 3:3 del foo1 foo1 = 10del foo2 print len(foo)A.1B.2C.3D.4E.A n excepti on is throw n50.What gets prin ted?E) names = Amir, Barry, Chales, Dao print n ames-1-1A.AB.rC.AmirD.DaoE.o49!51.What gets prin ted?B) names1 = Amir, Barry, Chales, Dao n am
30、es2 = n ames1n ames3 = n ames1:names20 = Alicenames31 = Bobsum = 0for ls in (n ames1, n ames2, n ames3): if ls0 = Alice:sum += 1if ls1 = Bob:sum += 10print sumA.11B.12C.21D.22E.3352.What gets prin ted?E) n ames1 = Amir, Barry, Chales, Dao loc = n amesl.i ndex(Edward)print locA.-1B.OC.4D.EdwardE.An e
31、xception is thrown53.What gets prin ted?B) names1 = Amir, Barry, Chales, Dao if amir in n ames1:print 1else:print 2A.1B.2C.A n excepti on is throw n54.What gets prin ted?C) names1 = Amir, Barry, Chales, Dao n ames2 = n ame .lo wer() for n49!ame in n ames1print n ames220A.iB.aC.cD.CE.An exception is
32、thrown55.What gets prin ted?B) numbers = 1,2, 3, 4nu mbers.appe nd(5,6,7,8)print len(nu mbers)A.4B.5C.8D.12E.A n excepti on is throw n56.Which of the following data structures can be used with the in operator to check if an item is inthe data structure?E)A.listB.setC.dictio naryD.None of the aboveE.
33、AII of the above57.Wat gets prin ted?D) list1 = 1,2, 3, 4 list2 = 5, 6, 7, 8print len( listl + Iist2)A.2B.4C.5D.8E.A n excepti on is throw n58.What gets prin ted?C)49!def addltem(listParam): listParam += 1mylist = 1,2, 3, 4 addltem(mylist) print len(m ylist)A.1B.4C.5D.8E.A n excepti on is throw n59.
34、What gets prin ted?E) my_tuple = (1,2, 3, 4) my_tuple.appe nd( (5, 6, 7) print len(m y tuple)A.1B.2C.5D.7E.An exception is thrown60.What gets prin ted?B) a = 1b = 2a,b = b,aprin t %d %d % (a,b)A.1 2B.2 1C.A n excepti on is throw nD.This program has un defi ned behavior61.What gets prin ted?A)def pri
35、n t_header(str): prin t +%s+ % strprin t_header.category = 1prin t_header.text = some infoprint_header(%d %s % (print header.category, print header.text)49!A.+1 some in fo+B.+%s+C.1D.some info62.What gets prin ted?C) def dostuff(param1, *param2):print type(param2)dostuff(apples, ba nan as, cherry, d
36、ates)A.strB.i ntC.tupleD.listE.dict63.What gets prin ted?( E)def dostuff(param1, *param2): print type(param2)dostuff(capitals, Ariz on a=Phoe ni x, Califor ni a=Sacrame nto, Texas=Aust in)A.inB.strC.tupleD.listE.dict64.What gets prin ted?B)def myfun c(x, y, z, a): print x + ynums = 1,2, 3, 4myfun c(
37、* nu ms)A.1B.3C.649!D.10E.A n excepti on is throw n65.How do you create a package so that the follow ing refere nee will work?C) p =mytools.myparser.MyParser()A.Declare the myparser package in mytools.pyB.Create an _init_.py in the home dirC.ln side the mytools dir create a _init_.pyD.Create a mypar
38、ser.py directory in side the mytools directoryE.This can not be done66.What gets prin ted?E) class A:def _init_(self, a, b, c): self.x = a + b + ca = A(1,2,3) b = getattr(a, x) setattr(a, x, b+1) print a.xA.1B.2C.3D.6E.767.What gets prin ted?E) class NumFactory: def _init_(self, n): self.val = n def timesTwo(self): self.val*= 2 def plusTwo(self): self.val += 2 f = NumFactory(2) for m in dir(f):mthd = getattr(f,m) if callable(mthd): mthd()print f.valA.2B.4C.6D. 8E.A n excepti on is throw n68.What gets prin ted?A)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 教育行業(yè)在線教育平臺的課程評價體系方案
- 造價咨詢合同
- 2025年天津貨運從業(yè)資格證模擬試題答案解析大全
- 2025年寧德貨物運輸駕駛員從業(yè)資格考試系統(tǒng)
- 電子消費券采購合同(2篇)
- 電力電量分配合同(2篇)
- 電池焊接維修合同(2篇)
- 2024年高考?xì)v史二輪復(fù)習(xí)“12+2+3”專項練第46題選做題專練
- 2024-2025學(xué)年四年級語文上冊第五單元19奇妙的國際互聯(lián)網(wǎng)教案2蘇教版
- 2024-2025學(xué)年高中化學(xué)第二章化學(xué)反應(yīng)與能量第二節(jié)化學(xué)能與電能2發(fā)展中的化學(xué)電源課時訓(xùn)練含解析新人教版必修2
- 川教版三年級下冊《生命生態(tài)安全》教學(xué)設(shè)計含教學(xué)計劃【附安全知識】
- SOR-04-014-00 藥品受托生產(chǎn)企業(yè)審計評估報告模板
- 足球場建設(shè)項目設(shè)計方案
- 兒童四宮格數(shù)獨96題-(由簡到難,支持打印)
- 2024-2030年傷口護理管理行業(yè)市場現(xiàn)狀供需分析及重點企業(yè)投資評估規(guī)劃分析研究分析報告
- 混凝土攪拌站安全生產(chǎn)風(fēng)險分級管控體系方案全套資料2021-2022完整實施方案模板
- 新生兒紅臀的預(yù)防和護理
- 《停車場規(guī)劃設(shè)計規(guī)范》
- eras在婦科圍手術(shù)
- 膝關(guān)節(jié)前十字韌帶扭傷查房
- 2024建設(shè)工程人工材料設(shè)備機械數(shù)據(jù)分類和編碼規(guī)范
評論
0/150
提交評論