您好,欢迎访问三七文档
1.whatdoesthefollowingcodedo?(B)defa(b,c,d):passA.definesalistandinitializesitB.definesafunction,whichdoesnothingC.definesafunction,whichpassesitsparametersthroughD.definesanemptyclass2.whatgetsprinted?Assumingpythonversion2.x(A)printtype(1/2)A.type'int'B.type'number'C.type'float'D.type'double'E.type'tuple'3.whatistheoutputofthefollowingcode?(E)printtype([1,2])A.type'tuple'B.type'int'C.type'set'D.type'complex'E.type'list'4.whatgetsprinted?(C)deff():passprinttype(f())A.type'function'B.type'tuple'C.type'NoneType'D.type'str'E.type'type'5.whatshouldthebelowcodeprint?(A)printtype(1J)A.type'complex'B.type'unicode'C.type'int'D.type'float'E.type'dict'6.whatistheoutputofthefollowingcode?(D)printtype(lambda:None)A.type'NoneType'B.type'tuple'C.type'type'D.type'function'E.type'bool'7.whatistheoutputofthebelowprogram?(D)a=[1,2,3,None,(),[],]printlen(a)A.syntaxerrorB.4C.5D.6E.78.whatgetsprinted?Assumingpythonversion3.x(C)print(type(1/2))A.type'int'B.type'number'C.type'float'D.type'double'E.type'tuple'9.Whatgetsprinted?(C)d=lambdap:p*2t=lambdap:p*3x=2x=d(x)x=t(x)x=d(x)printxA.7B.12C.24D.36E.4810.Whatgetsprinted?(A)x=4.5y=2printx//yA.2.0B.2.25C.9.0D.20.25E.2111.Whatgetsprinted?(C)nums=set([1,1,2,3,3,3,4])printlen(nums)A.1B.2C.4D.5E.712.Whatgetsprinted?(A)x=Truey=Falsez=Falseifxoryandz:printyeselse:printnoA.yesB.noC.failstocompile13.Whatgetsprinted?(C)x=Truey=Falsez=Falseifnotxory:print1elifnotxornotyandz:print2elifnotxoryornotyandx:print3else:print4A.1B.2C.3D.414.IfPYTHONPATHissetintheenvironment,whichdirectoriesaresearchedformodules?(D)A)PYTHONPATHdirectoryB)currentdirectoryC)homedirectoryD)installationdependentdefaultpathA.AonlyB.AandDC.A,B,andCD.A,B,andDE.A,B,C,andD15.Inpython2.6orearlier,thecodewillprinterrortype1ifaccessSecureSystemraisesanexceptionofeitherAccessErrortypeorSecurityErrortype(B)try:accessSecureSystem()exceptAccessError,SecurityError:printerrortype1continueWork()A.trueB.false16.Thefollowingcodewillsuccessfullyprintthedaysandthenthemonths(B)daysOfWeek=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']months=['Jan',\'Feb',\'Mar',\'Apr',\'May',\'Jun',\'Jul',\'Aug',\'Sep',\'Oct',\'Nov',\'Dec']printDAYS:%s,MONTHS%s%(daysOfWeek,months)A.trueB.false17.Assumingpython2.6whatgetsprinted?(A)f=Noneforiinrange(5):withopen(data.txt,w)asf:ifi2:breakprintf.closedA.TrueB.FalseC.None18.Whatgetsprinted?(C)counter=1defdoLotsOfStuff():globalcounterforiin(1,2,3):counter+=1doLotsOfStuff()printcounterA.1B.3C.4D.7E.noneoftheabove19.Whatgetsprinted?(C)printr\nwoowA.newlinethenthestring:woowB.thetextexactlylikethis:r\nwoowC.thetextlikeexactlylikethis:\nwoowD.theletterrandthennewlinethenthetext:woowE.theletterrthenthetextlikethis:nwoow20.Whatgetsprinted?(B)printhello'world'A.ononelinethetext:helloworldB.ononelinethetext:helloworldC.helloononelineandworldonthenextlineD.syntaxerror,thispythonprogramwillnotrun21.Whatgetsprinted?(E)print\x48\x49!A.\x48\x49!B.4849C.4849!D.4849!E.HI!22.Whatgetsprinted?(D)print0xA+0xaA.0xA+0xaB.0xA0xaC.14D.20E.0x2023.Whatgetsprinted?(E)classparent:def__init__(self,param):self.v1=paramclasschild(parent):def__init__(self,param):self.v2=paramobj=child(11)print%d%d%(obj.v1,obj.v2)A.NoneNoneB.None11C.11NoneD.1111E.Errorisgeneratedbyprogram24.Whatgetsprinted?(E)kvps={user,bill,password,hillary}printkvps['password']A.userB.billC.passwordD.hillaryE.Nothing.Pythonsyntaxerror25.Whatgetsprinted?(B)66%on1871timesaskedclassAccount:def__init__(self,id):self.id=idid=666acc=Account(123)printacc.idA.NoneB.123C.666D.SyntaxError,thisprogramwillnotrun26.Whatgetsprinted?(C)name=snowstormprint%s%name[6:8]A.stB.stoC.toD.torE.SyntaxError27.Whatgetsprinted?(D)name=snowstormname[5]='X'printnameA.snowstormB.snowXstormC.snowXtormD.ERROR,thiscodewillnotrun28.Whichnumbersareprinted?(C)foriinrange(2):printiforiinrange(4,6):printiA.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.Whatsequenceofnumbersisprinted?(B)values=[1,2,1,3]nums=set(values)defcheckit(num):ifnuminnums:returnTrueelse:returnFalseforiinfilter(checkit,values):printiA.123B.1213C.12131213D.11112233E.SyntaxError30.Whatsequenceofnumbersisprinted?(E)values=[2,3,2,4]defmy_transformation(num):returnnum**2foriinmap(my_transformation,values):printiA.2324B.4648C.11.512D.1112E.4941631.Whatnumbersgetprinted(C)importpickleclassaccount:def__init__(self,id,balance):self.id=idself.balance=balancedefdeposit(self,amount):self.balance+=amountdefwithdraw(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.deposit(200)printmyac.balancefd=open(archive,r)myac=pickle.load(fd)fd.close()printmyac.balanceA.500300B.500500C.600400D.600600E.30050032.Whatgetsprintedbythecodesnippetbelow?(B)importmathprintmath.floor(5.5)A.5B.5.0C.5.5D.6E.6.033.Whatgetsprintedbythecodebelow?(E)classPerson:def__init__(self,id):self.id=idobama=Person(100)obama.__dict__['age']=49printobama.age+len(obama.__dict__)A.1B.2C.49D.50E.5134.Whatgets
本文标题:PYTHON测试题
链接地址:https://www.777doc.com/doc-7028514 .html