ImageVerifierCode 换一换
格式:DOCX , 页数:36 ,大小:20.84KB ,
资源ID:27778331      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/27778331.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(PYTHON测试题.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

PYTHON测试题.docx

1、PYTHON测试题1.what does the following code do?(B)def a(b, c, d): passA.defines a list and initializes itB.defines a function, which does nothingC.defines a function, which passes its parameters throughD.defines an empty class2.what gets printed? Assuming python version 2.x(A)print type(1/2)A.B.C.D.E.3.

2、 what is the output of the following code?(E)print type(1,2)A.B.C.D.E.4. what gets printed?(C)def f(): passprint type(f()A.B.C.D.E.5. what should the below code print?(A)print type(1J) A.B.C.D.E.6. what is the output of the following code?(D)print type(lambda:None) A.B.C.D.E.7. what is the output of

3、 the below program?(D)a = 1,2,3,None,(),print len(a) A.syntax errorB.4C.5D.6E.78.what gets printed? Assuming python version 3.x(C)print (type(1/2) A.B.C.D.E.9. What gets printed?(C)d = lambda p: p * 2t = lambda p: p * 3x = 2x = d(x)x = t(x)x = d(x)print x A.7B.12C.24D.36E.4810. What gets printed?(A)

4、x = 4.5y = 2print x/y A.2.0B.2.25C.9.0D.20.25E.2111. What gets printed?(C)nums = set(1,1,2,3,3,3,4)print len(nums) A.1B.2C.4D.5E.712. What gets printed?(A)x = Truey = Falsez = Falseif x or y and z: print yeselse: print no A.yesB.noC.fails to compile13. What gets printed?(C)x = Truey = Falsez = False

5、if 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 4 A.1B.2C.3D.414. If PYTHONPATH is set in the environment, which directories are searched for modules?(D)A) PYTHONPATH directoryB) current directoryC) home directoryD) installation dependent de

6、fault path A.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 print error type 1 if accessSecureSystem raises an exception of either AccessError type or SecurityError type(B)try: accessSecureSystem()except AccessError, SecurityError: print error ty

7、pe 1continueWork() A.trueB.false16. The following code will successfully print the days and then the months(B)daysOfWeek = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sundaymonths = Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Decprint DAYS: %s, MONTHS %s % (daysOfWeek, months)

8、 A.trueB.false17. Assuming python 2.6 what gets printed?(A)f = Nonefor i in range (5): with open(data.txt, w) as f: if i 2: breakprint f.closed A.TrueB.FalseC.None18. What gets printed?(C)counter = 1 def doLotsOfStuff(): global counter for i in (1, 2, 3): counter += 1doLotsOfStuff()print counter A.1

9、B.3C.4D.7E.none of the above19. What gets printed?(C)print rnwoow A.new line then the string: woowB.the text exactly like this: rnwoowC.the text like exactly like this: nwoowD.the letter r and then newline then the text: woowE.the letter r then the text like this: nwoow20.What gets printed?(B)print

10、hello world A.on one line the text: hello worldB.on one line the text: helloworldC.hello on one line and world on the next lineD.syntax error, this python program will not run21.What gets printed?(E)print x48x49! A.x48x49!B.4849C.4849!D. 48 49!E.HI!22. What gets printed?(D)print 0xA + 0xa A.0xA + 0x

11、aB.0xA 0xaC.14D.20E.0x2023. What gets printed?(E)class parent: def _init_(self, param): self.v1 = paramclass child(parent): def _init_(self, param): self.v2 = paramobj = child(11)print %d %d % (obj.v1, obj.v2) A.None NoneB.None 11C.11 NoneD.11 11E.Error is generated by program24. What gets printed?(

12、E)kvps = user,bill, password,hillaryprint kvpspassword A.userB.billC.passwordD.hillaryE.Nothing. Python syntax error25. What gets printed?(B)66% on 1871 times askedclass Account: def _init_(self, id): self.id = id id = 666 acc = Account(123)print acc.id A.NoneB.123C.666D.SyntaxError, this program wi

13、ll not run26. What gets printed?(C)name = snow stormprint %s % name6:8 A.stB.stoC.toD.torE.Syntax Error27. What gets printed?(D)name = snow stormname5 = Xprint name A.snow stormB.snowXstormC.snow XtormD.ERROR, this code will not run28. Which numbers are printed?(C)for i in range(2): print ifor i in

14、range(4,6): print i A.2, 4, 6B.0, 1, 2, 4, 5, 6C.0, 1, 4, 5D.0, 1, 4, 5, 6, 7, 8, 9E.1, 2, 4, 5, 629. What sequence of numbers is printed?(B)values = 1, 2, 1, 3nums = set(values)def checkit(num): if num in nums: return True else: return Falsefor i in filter(checkit, values): print i A.1 2 3B.1 2 1 3

15、C.1 2 1 3 1 2 1 3D.1 1 1 1 2 2 3 3E.Syntax Error30. What sequence of numbers is printed?(E)values = 2, 3, 2, 4def my_transformation(num): return num * 2for i in map(my_transformation, values): print i A.2 3 2 4B.4 6 4 8C.1 1.5 1 2D.1 1 1 2E.4 9 4 1631. What numbers get printed(C)import pickleclass a

16、ccount: def _init_(self, id, balance): self.id = id self.balance = balance def deposit(self, amount): self.balance += amount def withdraw(self, amount): self.balance -= amountmyac = account(123, 100)myac.deposit(800)myac.withdraw(500)fd = open( archive, w ) pickle.dump( myac, fd)fd.close()myac.depos

17、it(200)print myac.balancefd = open( archive, r ) myac = pickle.load( fd )fd.close()print myac.balance A.500 300B.500 500C.600 400D.600 600E.300 50032. What gets printed by the code snippet below?(B)import mathprint math.floor(5.5) A.5B.5.0C.5.5D.6E.6.033. What gets printed by the code below?(E)class

18、 Person: def _init_(self, id): self.id = idobama = Person(100)obama._dict_age = 49print obama.age + len(obama._dict_) A.1B.2C.49D.50E.5134. What gets printed?(E)x = foo y = 2print x + y A.fooB.foo fooC.foo 2D.2E.An exception is thrown35. What gets printed?(E)def simpleFunction(): This is a cool simp

19、le function that returns 1 return 1print simpleFunction._doc_10:14A.simpleFunctionB.simpleC.funcD.funtionE.cool36. What does the code below do?(C)sys.path.append(/root/mods) A.Changes the location that the python executable is run fromB.Changes the current working directoryC.Adds a new directory to

20、seach for python modules that are importedD.Removes all directories for modsE.Changes the location where sub-processes are searched for after they are launched37. What gets printed?(C)import resum = 0pattern = backif re.match(pattern, backup.txt): sum += 1if re.match(pattern, text.back): sum += 2if

21、re.search(pattern, backup.txt): sum += 4if re.search(pattern, text.back): sum += 8print sum A.3B.7C.13D.14E.1538. Which of the following print statements will print all the names in the list on a seperate line(A)names = Ramesh, Rajesh, Roger, Ivan, Nico A.print n.join(names)B.print names.join(n)C.pr

22、int names.concatenate(n)D.print names.append(n)E.print names.join(%sn, names)39. True or false? Code indentation must be 4 spaces when creating a code block?(B)if error: # four spaces of indent are used to create the block print %s % msg A.TrueB.False40. Assuming the filename for the code below is /

23、usr/lib/python/person.pyand the program is run as: python /usr/lib/python/person.py What gets printed?(D)class Person: def _init_(self): pass def getAge(self): print _name_p = Person()p.getAge() A.PersonB.getAgeC.usr.lib.python.personD._main_E.An exception is thrown41. What gets printed(B)foo = prin

24、t type(foo) A.setB.dictC.listD.tupleE.object42. What gets printed?(C)foo = (3, 4, 5)print type(foo) A.intB.listC.tupleD.dictE.set43. What gets printed?(D)country_counter = def addone(country): if country in country_counter: country_countercountry += 1 else: country_countercountry = 1addone(China)add

25、one(Japan)addone(china)print len(country_counter) A.0B.1C.2D.3E.444. What gets printed?(D)confusion = confusion1 = 1confusion1 = 2confusion1 += 1sum = 0for k in confusion: sum += confusionkprint sum A.1B.2C.3D.4E.545. What gets printed?(C)confusion = confusion1 = 1confusion1 = 2confusion1.0 = 4sum =

26、 0for k in confusion: sum += confusionkprint sum A.2B.4C.6D.7E.An exception is thrown46.What gets printed?(E)boxes = jars = crates = boxescereal = 1boxescandy = 2jarshoney = 4cratesboxes = boxescratesjars = jarsprint len(cratesboxes)A.1B.2C.4D.7E.An exception is thrown47. What gets printed?(E)number

27、Games = numberGames(1,2,4) = 8numberGames(4,2,1) = 10numberGames(1,2) = 12sum = 0for k in numberGames: sum += numberGameskprint len(numberGames) + sum A.8B.12C.24D.30E.3348. What gets printed?(A)foo = 1:1, 2:2, 3:3foo = print len(foo) A.0B.1C.2D.3E.An exception is thrown49. What gets printed?(B)foo = 1:1, 2:2, 3:3del foo1foo1

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1