下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024水果冷鏈物流配送服務(wù)合同3篇
- 2025年中國(guó)地方招商引資行業(yè)市場(chǎng)運(yùn)營(yíng)現(xiàn)狀及投資規(guī)劃研究建議報(bào)告
- 二零二五年度SPF豬飼養(yǎng)保險(xiǎn)理賠服務(wù)合同3篇
- 2025年中國(guó)腕式止鼾器市場(chǎng)供需現(xiàn)狀及投資戰(zhàn)略研究報(bào)告
- 2025年中國(guó)寧泌泰膠囊行業(yè)市場(chǎng)調(diào)研及未來(lái)發(fā)展趨勢(shì)預(yù)測(cè)報(bào)告
- 2024民房租賃期滿(mǎn)買(mǎi)賣(mài)合同模板3篇
- 二零二五奧迪A6L購(gòu)車(chē)與個(gè)性化定制合同3篇
- 2025年度SPF豬飼養(yǎng)產(chǎn)業(yè)鏈金融產(chǎn)品開(kāi)發(fā)與推廣合同
- 2025年環(huán)保節(jié)能空調(diào)產(chǎn)品定制銷(xiāo)售合同3篇
- 二零二五年加盟店線(xiàn)上線(xiàn)下銷(xiāo)售渠道合作協(xié)議2篇
- 頻譜儀N9020A常用功能使用指南
- 天津高考英語(yǔ)詞匯3500
- 2023年智慧電廠(chǎng)垃圾焚燒發(fā)電廠(chǎng)解決方案
- 人資法務(wù)技能指導(dǎo)【紅皮書(shū)完整版】
- 三年級(jí)下冊(cè)數(shù)學(xué)教案-6練習(xí)五-北師大版
- 清潔驗(yàn)證管理規(guī)程
- 建設(shè)工程質(zhì)量檢測(cè)作業(yè)指導(dǎo)書(shū)+儀器設(shè)備操作規(guī)程2021版
- 醫(yī)院食堂食品留樣銷(xiāo)毀記錄表
- 急診急救藥品用法作用一覽表
- 項(xiàng)目施工周報(bào)模板
- 梅毒診療指南(2014版)
評(píng)論
0/150
提交評(píng)論