![PYTHON測精彩試題_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/4/f4df8d2e-88c4-46f5-a0d9-69090d383618/f4df8d2e-88c4-46f5-a0d9-69090d3836181.gif)
![PYTHON測精彩試題_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/4/f4df8d2e-88c4-46f5-a0d9-69090d383618/f4df8d2e-88c4-46f5-a0d9-69090d3836182.gif)
![PYTHON測精彩試題_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/4/f4df8d2e-88c4-46f5-a0d9-69090d383618/f4df8d2e-88c4-46f5-a0d9-69090d3836183.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quá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.
2、 vtype intB. 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 prin t?
3、A) print type(1J)A. B. C. D. E. 6. 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
4、 prin ted? Assu ming pyth on vers ion 3.xC) print (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)prnt 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. W
5、hat gets prin ted?C) nums = set(1,1,2,3,3,3,4) print len(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 = Falsez = Falseif not x or y:print 1elif not x or not y an
6、d z:print 2elif not x or y or not y and x: print 3else:print 4A. 1B. 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
7、 CD. A, B, and DE. A, B, C, and D15. In python 2.6 or earlier, the code will print error type 1 if accessSecureSystem raises an excepti on of either AccessError type or SecurityError type() try:accessSecureSystem() except AccessError, SecurityError:prin t error type 1con ti nu eWork()A. trueB. false
8、16. The following code will successfully print the days and then the monthsB) daysOfWeek = Mo nday,Tuesday,mon ths =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
9、 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 2:breakprint f.closedA. TrueB. FalseC. N one18. What gets prin ted?C) coun ter = 1 def doLotsOfStuff(): global coun ter for i in (1,2, 3):coun ter += 1doLotsOfStuff()print coun terA. 1B. 3C. 4D. 7E. none
10、 of the above19. What gets prin ted?C) print rn woowA. new line then the string: woowB. the text exactly 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 hell
11、o worldA. on one line the text: hello worldB. on one line the text: helloworldC. hello on one line and world 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. 48E. HI!22. What gets prin ted?D) prin t 0xA + OxaA. OxA
12、+ 0xaB. OxA 0xaC. 14D. 20E. 0x2023. What gets prin ted?E) class pare nt:def _init_(self, param): self.v1 = paramclass 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. Wh
13、at gets prin ted?E)kvps = user,bill, password,hillaryprint kvpspasswordA. userB. billC. passwordD. hillaryE. Nothi ng. Pyth on syn tax error25. What gets prin ted?B)66% on 1871 times askedclass Acco unt:def _init_(self, id): self.id = id id = 666acc = Accou nt(123) print acc.idA. No neB. 123C. 666D.
14、 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 tax 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
15、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, 629. 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 True else:retur n Falsefor i
16、 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) values = 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
17、 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, amoun t): self.bala nee += amount def withdraw(self, amoun t): self.bala nee -= amountmyac = accou nt(123, 100) myac.deposit(800) myac.w
18、ithdraw(500)fd = ope n( archive, w) pickle.dump( myac, fd) fd.close()myac.deposit(200) print myac.bala neefd = ope n( archive, r) myac = pickle .lo ad( fd ) fd.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 math
19、print 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_age = 49print obama.age + len (obama.dict)A. 1B. 2C. 49D. 50E. 5134. What gets prin ted?E) x = foo y = 2 print x + yA. fooB. foo f
20、ooC. 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. simpleF un ctio nB. simpleC. fu ncD. fun ti onE. cool36. What does the code below do?C) sys.path.appe nd(/root/mods)A. Ch
21、a 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 directories for modsE. Cha nges the locati on where sub-processes are searched for after they are laun ched37. W
22、hat 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(pattern, text.back):sum += 8print sumA. 3B. 7C. 13D. 14E. 1538. Which of the following print statements will pri
23、nt all the names in the list on a seperate lin eA) n ames = 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 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
24、 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 program is run as:pytho n /usr/lib/pyth on/pers on .pyWhat gets prin ted?D) class Pers on:def
25、 _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. listD. tupleE. object42. What gets prin ted?C) foo = (3, 4, 5) print type(foo)A. i n
26、tB. 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 on e(Japa n)add on e(chi na)print len(coun try c oun ter)A. 0B. 1C. 2D. 3E. 444
27、. 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 onkprint sumA. 1B. 2C. 3D. 4E. 545. What gets prin ted?C) con fusi on = con fusi on1 = 1con fusio n1 = 2con fusio n1.0 = 4sum = 0for k in con fusi on:sum += con fusi onk
28、print 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 on is throw n47. What gets prin ted?E)nu mberGames = nu mbe
29、rGames(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 exception is thrown49. What gets prin ted?B) foo = 1:1,
30、 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. o51. What gets prin ted?B) names1 = Amir, Barry, Chales, Dao n ames2 = n ames1n ames3 = n ames1: names20 =
31、 Alice names31 = Bob sum = 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) names1 = Amir, Barry, Chales, Dao loc = n amesl.i ndex(Edward) print locA. -1B. OC. 4D. EdwardE. A n excepti on is throw n53. Wh
32、at 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 n ame in n ames1print n ames220A. iB. aC. cD. CE. A n excepti on is throw n55. What
33、 gets prin ted?B) numbers = 1,2, 3, 4 nu 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 in the data structure?E)A. listB. setC. dictio naryD. None of the aboveE.
34、AII of the above57. Wat gets prin ted?D) list1 = 1,2, 3, 4 list2 = 5, 6, 7, 8 print len( listl + Iist2)A. 2B. 4C. 5D. 8E. A n excepti on is throw n58. What gets prin ted?C)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
35、throw n59. 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. A n excepti on is throw n60. 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. Wha
36、t gets prin ted?A) def prin t_header(str):prin t +%s+ % str prin t_header.category = 1prin t_header.text = some infoprint_header(%d %s % (print header.category, print header.text)A. +1 some in fo+B. +%s+C. 1D. some info62. What gets prin ted?C) def dostuff(param1, *param2):print type(param2)dostuff(
37、apples, ba nan as, cherry, dates)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,
38、 a): print x + ynums = 1,2, 3, 4myfun c(* nu ms)A. 1B. 3C. 6D. 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
39、 mytools dir create a _init_.pyD. Create a myparser.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)
40、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) one = chr(104)two = chr(105)prin t %s%s % (one, two)A. hiB. hC. ln side the mytools dir create a _init_.py and myparser.pyD. 104105E. 10469. What gets prin ted?A) x = 0y = 1a = cmp(x,y)if a 2 or num 0: ret
溫馨提示
- 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)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 小學(xué)二年級數(shù)學(xué)上冊口算題
- 2024-2025年高中化學(xué)課時分層作業(yè)5元素的電負性及其變化規(guī)律含解析魯科版選修3
- 西門子油煙機指導(dǎo)書
- 2025年年度尊重生命總結(jié)報告
- 二次消防改造工程合同范本
- 海南經(jīng)貿(mào)職業(yè)技術(shù)學(xué)院《建筑構(gòu)造Ⅰ》2023-2024學(xué)年第二學(xué)期期末試卷
- 福州科技職業(yè)技術(shù)學(xué)院《德語口譯》2023-2024學(xué)年第二學(xué)期期末試卷
- 常州信息職業(yè)技術(shù)學(xué)院《中學(xué)語文課程與教學(xué)論》2023-2024學(xué)年第二學(xué)期期末試卷
- 宿遷學(xué)院《編譯原理》2023-2024學(xué)年第二學(xué)期期末試卷
- 烏蘭察布職業(yè)學(xué)院《建筑物理》2023-2024學(xué)年第二學(xué)期期末試卷
- 四川省綿陽市2025屆高三上學(xué)期第二次診斷性考試語文試題(含答案)
- 2024版《糖尿病健康宣教》課件
- 勞動防護用品知識考試試題(含答案)
- 高中教師業(yè)務(wù)知識考試 數(shù)學(xué)試題及答案
- GB/T 9290-2008表面活性劑工業(yè)乙氧基化脂肪胺分析方法
- GB/T 22751-2008臺球桌
- GB/T 13234-2009企業(yè)節(jié)能量計算方法
- 易經(jīng)中的人生智慧-職業(yè)生涯規(guī)劃與個人發(fā)展課件
- ABAP開發(fā)培訓(xùn)經(jīng)典入門課件
- 社區(qū)工作者經(jīng)典備考題庫(必背300題)
- 北郵工程數(shù)學(xué)作業(yè)1-4
評論
0/150
提交評論