雨課堂學(xué)堂在線學(xué)堂云《python程序設(shè)計(jì)(寧波城市職業(yè)技術(shù)學(xué)院)》單元測(cè)試考核答案_第1頁(yè)
雨課堂學(xué)堂在線學(xué)堂云《python程序設(shè)計(jì)(寧波城市職業(yè)技術(shù)學(xué)院)》單元測(cè)試考核答案_第2頁(yè)
雨課堂學(xué)堂在線學(xué)堂云《python程序設(shè)計(jì)(寧波城市職業(yè)技術(shù)學(xué)院)》單元測(cè)試考核答案_第3頁(yè)
雨課堂學(xué)堂在線學(xué)堂云《python程序設(shè)計(jì)(寧波城市職業(yè)技術(shù)學(xué)院)》單元測(cè)試考核答案_第4頁(yè)
雨課堂學(xué)堂在線學(xué)堂云《python程序設(shè)計(jì)(寧波城市職業(yè)技術(shù)學(xué)院)》單元測(cè)試考核答案_第5頁(yè)
已閱讀5頁(yè),還剩24頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

第1題Whichofthefollowingarethefeaturesofthepythonlanguage?ASimpleandbeautifulgrammarBRichclasslibraryCOpensource,portableDGoodexpansibility正確答案:ABCD第2題Pythonisacrossplatform,opensource,andfreeadvanceddynamicprogramminglanguage.第3題WhichareascanPythonbeappliedto?AArtificialIntelligenceBDataAnalysisCEmbeddedDevelopmentDAutomatedOperationandMaintenance正確答案:BAD第1題MultipleversionsofPythoncannotbeinstalledonthesamecomputer.第2題TherunningmethodsofPythonprogramsincludecodebasedandinteractive.第3題Thefollowingidesbelongingtopythonare:AIDLEBturtleCanacondaDpycharm正確答案:ACProgramStatementOverview第1題Youcanuse"if"asavariablenameinPython.第2題Pythonusesindentationtoshowlogicalrelationshipsbetweencode.第3題ThereisonlyonewaytocommentPythoncode,andthatiswiththe#symbol.第4題Pythonvariablesmustbedeclaredbeforetheycanbeused,andoncedeclared,theirtypescannotbechangedfromwithinthecurrentscope.第5題Thetypeofvariablexafterexecutingthefollowingcodeisx=input(“Pleaseenteranumber.”)AStringBIntegerCListDNoneType第6題ThemarkupforaPythonlanguageblockisAsemicolonBcommaCindentationD/NumericOperation第1題Whenentering"3"onthekeyboard,theoutputresultofthefollowingprogramisr=input("Pleaseentertheradius:")

ar=3.1415*r*r

print("{:.0f}".format(ar))A28B28.27C29DTypeError第2題Whichofthefollowingarepythondatatypes:AintegerBstringClistDdict正確答案:ABDC第3題Theresultof2+2.5isA4.5B5C4D錯(cuò)誤StringOperation第1題Whichofthefollowingexpressionsislegal?A“A”+5B“A”-5C“A”*5D“A”/5第2題Theresultof"ab"+"c"*2isAabc2BabcabcCabccDababcc第3題Givenx=3,theassignmentstatementx='abcedfg'cannotbeexecutedproperly.第4題Theadditionoperatorcanbeusedtoconcatenatestringsandgeneratenewstrings.第5題Theresultofthefollowingstatementis:

s="abcdefg"print(s[1:3])AabcBbcdCbcDabApplicationsofStringOperation第1題Themethodtogetthelengthofthestringsis

As.len()Bs.lengthC

len(s)Dlength(s)第2題Ifa='abcd',ifyouwanttochange'a'to'abce',thefollowingstatementiscorrectAa[-1]='e'Ba.replace('d','e')Ca[4]='e'D

a=a[0:3]+'e'第3題Givethefollowingcode:s='PythonisOpenSource!'

print(s[0:].upper())TheoutputoftheabovecodeisAPYTHONBPYTHONISOPENSOURCECPythonisOpenSource!DPYTHONISOPENSOURCE!第4題Theoutputofthefollowingcodeiss1="Thepythonlanguageisascriptinglanguage."

s2=s1.replace('scripting','general')

print(s2)AThepythonlanguageisascriptinglanguage.B

['The','python','language','is','a','scripting','language.']CThepythonlanguageisagenerallanguage.DSystemError第5題Theoutputofthefollowingcodeiss="Thepythonlanguageisacrossplatformlanguage."

print(s.find('language',30))ASystemErrorB40C11D10第6題Theoutputofthefollowingcodeiss="Thepythonlanguageisamultimodellanguage."

print(s.split(''))AThepythonlanguageisamultimodellanguage.B['The','python','language','is','a','multimodel','language.']CThepythonlanguageisamultimodellanguage.DSystemError第7題Theoutputofthefollowingcodeisa="Python"

b="ASuperlanguage"

print("{:->10}:{:-<19}".format(a,b))A----Python:ASuperlanguage----B----Python:----ASuperlanguageCThepythonlanguageisamultimodellanguage.DPython----:----ASuperlanguage第8題Ofthefollowingoptions,theoutputresultis"False"isA

>>>'python'<'pypi'B

>>>'ABCD'=='abcd'.upper()C

>>>'python123'>'python'D

>>>''<'a'第9題Theoutputofthefollowingcodeisa="alex"

b=a.capitalize()

print(a,end=",")

print(b)Aalex,ALEXBALEX,alexCalex,AlexDAlex,Alex第10題Theoutputofthefollowingcodeis

str1="mysqlsqlserverPostgresQL"

str2="sql"

ncount=str1.count(str2)

print(ncount)A2B5C4D3第11題ThestripmethodofastringworksasARemovesthespecifiedcharactersatthebeginningandendofthestringBRemovesthespecifiedcharacterattheendofthestringCRemovesthecharacterspecifiedinthestringheaderDSlicingastringbyspecifyingaseparator第12題Whichofthefollowingmethodscanmakethefirstletterofallwordscapitalized?AcapitalizeBtitleCupperDljustIntruductiontoturtle第1題goto(50,100)meansmovetothecoordinatepositionof(50,100).第2題speed(0)indicatesthefastestspeed,andspeed(1)indicatestheslowestspeed.第3題Whichofthefollowingdoesnotchangethedirectionofthepen?Aright()Bleft()Cbk()Dseth()第4題ThedefaultdirectionforturtleisALeftBRightCUpDDown第5題Whichofthefollowingcodedrawsacircle?Acircle(50,steps=3)Bcircle(50,180)Ccircle(50)Dcircle(50,0)SelectionStructure第1題Question:Enterayear,amonth,aday,judgethisdayisthenumberofdaysofthisyear?Ideas:TakeMarch5asanexample,youshouldfirstaddupthefirsttwomonths,andthenadd5days,thatis,thenumberofdaysoftheyear,inspecialcases,leapyearsandinputmonthsgreaterthan3needtoconsideraddingonemoreday:year=int(input('year:\n'))month=int(input('month:\n'))day=int(input('day:\n'))months=[0,31,59,90,120,151,181,212,243,273,304,334]if0<=month<=12:

#Determinetheinputmonth

sum=months[month-1]else:

print('dataerror')sum+=dayleap=0if__________________________:#Judgewhetheritisanormalyearoraleapyear

leap=1if(leap==1)and(month>2):

sum+=1print('itisthe%dthday.'%sum)A(year%400==0)and((year%4==0)or(year%100!=0))B(year%400==0)and((year%4==0)and(year%100!=0))C(year%400=0)or((year%4=0)and(year%100!=0))D(year%400==0)or((year%4==0)and(year%100!=0))第2題Question:UsethenestingofConditionaloperatortocompletethisquestion:studentswithacademicscores>=90arerepresentedbyA,thosewithacademicscoresbetween70-80arerepresentedbyB,thosewithacademicscoresbetween70-80arerepresentedbyC,thosewithacademicscoresbetween60-70arerepresentedbyB,andthosewithacademicscoresbelow60arerepresentedbyE.Idea:(a>b)?a:bThisisabasicexampleoftheConditionaloperator.score=int(input('inputscore:'))ifscore>=90:grade='A'______________grade='B'elifscore>=70:grade='C'elifscore>=60:grade='D'else:grade='E'print('%dbelongsto%s'%(score,grade))Aelifscore<80:Belifscore<=80:Celifscore<=80:Delifscore>80:LoopStructure----WhileLoop第1題Ifkisaninteger,thefollowingwhileloopexecutesthenumberoftimes:A9B10C11D100第2題Whichofthefollowingstatementsiscorrect?AThe“continue”statementendstheexecutionoftheentireloopBYoucanonlyusea“break”statementinsidealoopCUsinga“break”statementora“continue”statementinsidealoophasthesameeffectDWhenexitingfromamultilevelloopnesting,youcanonlyusethe“goto”statement第3題Whichofthefollowingstatementswillloopindefinitely?AwhileFalse:

breakBwhile1<10:

time.sleep(10)CwhileTrue:

breakDa=[3,-1,',']i=0whilei<=len(a):

ifnota[0]:

breakLoopStructure----ForLoop第1題Problem:Findthevalueof

s=a+aa+aaa+aaaa+aa...a,whereaisanumber.Forexample,2+22+222+222...2(atotalof5numbersareaddedatthistime),howmanynumbersareaddediscontrolledbythekeyboard.Demand:Findthevalueof

s=a+aa+aaa+aaaa+aa...a,whereaisanumber.Idea:Calculatethevalueofeachitemfirst.Tn=0Sn=[]n=int(input('n=:'))a=int(input('a=:'))forcountinrange(n):Tn=Tn+a_______________Sn.append(Tn)printTnSn=reduce(lambdax,y:x+y,Sn)print(Sn)Aa=a//10Ba=a*10Ca=a+10Da=a**10第2題“foriinrange(20)”and“foriinrange(20,40)”areequivalentiftheyareusedonlytocontrolthenumberofloops.第3題Therearefournumbers:1,2,3,4,howmanydifferentandnon-repeatingthree-digitnumberscanbeformed?Whatarethey?Programsourcecode:foriinrange(1,5):forjinrange(1,5):forkinrange(1,5):____________________print(i,j,k)ThemissingstatementisAif(i!=k)and(i!=j)or(j!=k):Bif(i!=k)or(i!=j)and(j!=k):Cif(i!=k)or(i!=j)or(j!=k):Dif(i!=k)and(i!=j)and(j!=k):第4題Problem:Output9*9multiplicationtable.Idea:Branchandcolumnconsideration,atotalof9rowsand9columns,icontrolrow,jcontrolcolumn.foriinrange(1,10):______________________:result=i*jprint('%d*%d=%-3d'%(i,j,result))

print('')Aforjinrange(1,10)Bforjinrange(10)Cforjinrange(1,9)Dforjinrange(9)ComprehensiveApplicationofFlowControl第1題Printoutallevennumbersupto100,5perlinej=0foriin_____________

print("%4d"%i,end="")

j=j+1

ifj%5==0:

print()ThemissingstatementisArange(2,101,2):Brange(2,102,2):Crange(2,100,2):Drange(2,101):第2題Problem:Determinehowmanyprimestherearebetween101and200andoutputalltheprimes.Methodofjudgingprimenumbers:useanumbertoremove2tosqrt(thisnumber),ifitcanbeevenlydivided,itindicatesthatthisnumberisnotprime,andviceversa.h=0leap=1frommathimportsqrtfromsysimportstdoutforminrange(0,201):

k=int(sqrt(m+1))

foriinrange(2,k+1):

if______:leap=0break

ifleap==1:

print('%-4d'%m)

h+=1

ifh%10==0:print('')

leap=1print('Thetotalis%d'h)Am%i==0Bm%i==1Ci%m==0Di%m==1第3題Title:Printoutallthe"Narcissisticnumbernumber".Theso-called"Narcissisticnumber"referstoathreedigitnumberwhosecubicsumofeachdigitequalstothenumberitself.Forexample,153isa"Narcissisticnumbernumber"because153=1tothethirdpower+5tothethirdpower+3tothethirdpower.Requirement:printall"Narcissisticnumbernumber",forexample:153isa"Narcissisticnumbernumber",because153=1cubic+5cubic+3cubicIdea:Usetheforlooptocontrol100-999numbers,anddecomposeeachnumberintoone,ten,andhundreds.forninrange(100,1000):i=n//100_________________

k=n%10

ifn==i**3+j**3+k**3:

print(n)Aj=(n/10)%10Bj=(n//10)%10Cj=(n%10)%10Dj=(n%10)//10第4題Problem:Factoringapositiveintegerintoprimefactors.Forexample,enter90andprintout90=2*3*3*5.Idea:Todecomposetheprimefactorofn,weshouldfirstfindaminimumprimenumberk,andthencompletethefollowingsteps:(1)Ifthisprimenumberisequalton,itmeansthattheprocessofdecomposingtheprimefactorhasended,anditcanbeprintedout.(2)Ifnisnotequaltok,butnisdivisiblebyk,thenthevalueofkshouldbeprintedout,andndividedbythequotientofk,asthenewpositiveintegeryoun,repeatthefirststep.(3)Ifnisnotdivisiblebyk,thenk+1isusedasthevalueofkandthefirststepisrepeated.fromsysimportstdoutn=int(input("inputnumber:"))print("n=%d"%n)foriinrange(2,n+1):while__________

ifn%i==0:

stdout.write(str(i))

stdout.write("*")

n=n/i

else:

breakprint("%d"%n)An<i:Bn>i:Cn==i:Dn!=i:第5題Question:Aninteger,itisaperfectsquareafteradding100,plus168isaperfectsquare.Whatisthenumber?importmathforiinrange(10000):x=int(math.sqrt(i+100))y=int(math.sqrt(i+168))if____________________________________:print(i)A(x*x=i+100)and(y*y=i+168)B(x*x==i+100)&&(y*y==i+168)C(x*x==i+100)and(y*y==i+168)D(x*2==i+100)and(y**2==i+168)RandomModule第1題TogeneraterandomnumbersinPython,youshoulduseAmathmoduleBrandom

moduleCnumpy

moduleDpygame

module第2題WhichofthefollowingisnottrueabouttherandommoduleinPython?ASetthesamerandomseedandgeneratethesamerandomnumbereachtimetherandomfunctioniscalled.Bimportallfunctionsoftherandomlibraryby"fromrandomimport*".CTheoutputofuniform(0,1)isdifferentfromthatofuniform(0.0,1.0)inthattheformeroutputsrandomintegersandthelatteroutputsrandomdecimals.Drandint(a,b)istogenerateanintegerbetween[a,b],possiblyincludingaandb.第3題

Thefunctionofthe()methodinthepythonstandardlibraryrandomistorandomlyselect1elementfromthesequence.Achoice()Bsample()Crandint()Duniform()第4題Thesample(seq,k)methodinthepythonstandardlibraryrandomselectskelementsof(

)fromasequence.ArepeatedBnonrepeatedCrepeatedornonrepeatedD

specified

ExceptionHandling第1題ThekeyusedtothrowanexceptioninpythonisAtryBexceptCraiseDfinally第2題Exceptionhandling,suchasreleasingresources,closingfiles,andclosingdatabases,isdonebyAtryclauseBcatch

clauseCfinally

clauseDraise

clause第3題Whichofthefollowingistruewhenamethodencountersanexceptionandyoudon'tknowhowtohandleitAcatchexceptionBthrowexceptionCdeclareexceptionDnestedexception第4題WhichofthefollowingstatementsaboutPythonexceptionhandlingiswrong?AExceptionsintheprogramcanbecapturedandprocessedBStatementssuchas"else"and"finally"canbeusedintheexceptionhandlingstructureCExceptionsandsyntaxerrorsaretwotypesofprogramerrorsDStatementssuchastryandexceptareusedtohandleexceptionsFunctionDefinitionandCall第1題Whendefiningafunction,evenifthefunctiondoesnotneedtotakeanyparameters,apairofemptyparenthesesmustberetainedtoindicatethatitisafunction.第2題WhenyoudefineaPythonfunction,youmustspecifythereturnvaluetypeofthefunction.第3題deff():

globala,b

t=a

a=b

b=t

a=1

b=2

f()

print(a,b)TheresultofrunningtheabovecodeisA11B12C22D21Functionparameterpassingandreturnvalue第1題WhenyoudefineaPythonfunction,ifthereisnoreturnstatementinthefunction,thenullvalueNoneisreturnedbydefault.第2題Ifafunctionhasdefaultparameters,thenallparametersmustbesettodefaultvalues.第3題Localvariablesdefinedwithinafunctionareautomaticallydeletedwhenthefunctioncallends.第4題Insideafunction,youcanuseglobaltodeclaretheuseofexternalglobalvariables,oryoucanuseglobaltodefineglobalvariablesdirectly.第5題Variableswiththesamenameindifferentscopesdonotaffecteachother,thatis,variableswiththesamenamecanbedefinedindifferentscopes.第6題ThefunctionisasfollowsdefchanageList(list):

list.append("end")print("list",list)#Callstrs=['1','2']chanageList(strs)print("strs",strs)ThefollowingcorrectoutputforthevaluesofstrsandlistisAstrs['1','2']

Blist

['1','2']Clist['1','2',’end’]Dstrs

['1','2',’end’]正確答案:CD第7題deff():

globala,b

t=a

a=b

b=t

a=1

b=2

f()

print(a,b)

TheresultofrunningtheabovecodeisA11B12C22D21第8題deff(a,b):

t=a

a=b

b=t

a=1

b=2

f(a,b)

print(a,b)

TheresultofrunningtheabovecodeisA22B21C12D11第9題deffun(x,y):

globaly

t=x

x=y

y=t

x=0

y=1

fun(x,y)

print(x,y)TheresultofrunningtheabovecodeisA00B10C01D11第10題Thefunctionfprintsout6permutationsof1,2,3,andthevacancystatementisdeff(n):

forainrange(1,n):forbinrange(1,n):

forcinrange(1,n):

if______________:print(a,b,c)

_________Aa!=bandb!=candc!=a

f(4)Ba!=bandb!=candc!=a

f(3)Ca!=bandb!=c

f(4)Da!=bandb!=c

f(3)第11題deff(n):

ifn==0:return0

elifn==1:return1

returnf(n-1)+f(n-2)

print(4)

TheresultofrunningtheabovecodeisA3B1C4D2第12題deff(s):

t=""

forxins:t=x+t

returnt

s="xyz"

print(f(s))

TheresultofrunningtheabovecodeisAzyxBxyzCzxyDyxzSpecialFormsofFunctions第1題Topic:Fibonacciseries.Requirements:Fibonaccisequence:0,1,1,2,3,5,8,13,21,34,....Outputthe100thfibonumberIdea:Accordingtothelawofsequence,itcanbeconcludedthatthenextvalueisthesumoftheprevioustwovaluesdeffib(n):

ifn==1orn==2:return1

______________________

print(fib(100))Areturnfib(n-1)

returnfib(n-2)Breturnfib(n)+fib(n-2)Cfib(n-2)+fib(n-2)Dreturnfib(n-1)+fib(n-2)第2題Topic:Fibonacciseries.Requirements:Fibonaccisequence:0,1,1,2,3,5,8,13,21,34,....Outputthe100thfibonumberIdea:Accordingtothelawofsequence,itcanbeconcludedthatthenextvalueisthesumoftheprevioustwovaluesdeffib(n):

a,b=1,1

foriinrange(n-1):____________________

returnaprintfib(100)Aa,b=a+b,bBb,a=b,a+bCa,b=b,a+bDa,b=a+b,a第3題Topic:Usingrecursivemethodtofind5!.Idea:Recursiveformula:fn=fn_1*4!deffact(j):

sum=0

ifj==0:sum=1

else:sum=______________

returnsum

foriinrange(5):

print('%d!=%d'%(i,fact(i)))A(j+1)*fact(j+1)Bj*fact(j)Cj*fact(j-1)D(j-1)*fact(j-1)Module第1題Usethegenerichelpfunction(modulename)toviewinformationaboutspecificfunctionsunderamodule.第2題Usethesysmodulesys.modules.keys()toviewinformationaboutallmodules.第3題AmoduleisafilethatholdsPythoncode.第4題Boththe"frommodulenameimport*"statementandthe"importmodulename"statementcanimporttheentirecontentofthespecifiedmodule.Incontrasttothe“frommodulenameimport*”,theimportedcontentof"importmodulename"statementdoesnotneedtospecifythemodulename,canbedirectlyinvoked,moreconvenienttouse,soitismorerecommendedtoimporttheentirecontentofthespecifiedmoduleinthiswayintheprogram.第5題Thekeywordforimportingmodulesintopythonis

AimportBformCinputDdefineListcreationandbasicoperations第1題Assuminganon-emptylistx,thenx.append(3),x=x+[3]andx.insert(0,3)arebasicallythesameintermsofexecutiontime.第2題Assumingxisalistobject,thenx.op()andx.op(-1)havethesameeffect.第3題Elementsinthelistcanonlybeaccessedbyslicing,andcannotbemodifiedbyslicing.第4題Usetheremove()methodoflistobjectstoremovethespecifiedelementthatfirstappearsinthelist,andtothrowanexceptionifthespecifiedelementtoremovedoesnotexistinthecolumn.第5題InsertinganelementintoalistusingthePythonlistmethodinsert()changestheindexoftheelementaftertheinsertpositioninthelist.第6題Deletinganelementfromalistusingthedelcommandortheremove()methodofalistobjectaffectstheindexofsomeelementsinthelist.第7題Theappend()methodofalistobjectisanin-placeoperationthatappendsanelementtotheendofthelist.第8題Improvethefollowingprogramstatementssothattheoutputisthecontentsofthealist:a=[1,2,3,4,5,6,7,8,9,0]

________

print(b)Ab=a[:]Bb=a[0:9]Cb=a[0:0]Da=b[9:9]第9題Inputthestudentname,addittoalistst,untiltheinputnameisempty,andfinallyoutputst.st=[]

whileTrue:

s=input()

ifs!="":__________

else:break

print(st)Ast.append(s)Bst.insert(s)Cst.add(s)Ds.append(st)第10題Topic:Giveapositiveintegerwithnomorethan5digits,therequirementsare:first,findhowmanydigitsitis,second,printoutthenumbersinreverseorder.x=int(input("inputanumber:"))

a=x//10000

________________

c=x%1000//100

d=x%100//10

e=x%10

ifa!=0:

print("thereare5",e,d,c,b,a)

elifb!=0:

print("thereare4",d,c,b,a)

elifc!=0:

print("thereare3",e,d,c)

elifd!=0:

print("thereare2",e,d)

else:

print("thereare1",e)Ab=x%10000//1000Bb=x//10000//1000Cb=x//10000%1000Db=x%10000%1000第11題Question:Inputthreeintegersx,y,z,pleaseoutputthesethreenumbersfromsmalltolarge.Idea:Wefindawaytoputthesmallestnumberonx,firstcomparexwithy,ifxisgreaterthany,thenswapxwiththevalueofy,thencomparexwithz,ifxisgreaterthanz,thenswapxwiththevalueofz,sothatxcanbeminimized.m=[]

foriinrange(0,3):

n=int(input('input:'))

m.append(n)

________print(m)Am.sort()Bm.sort(true)Cm.order(true)Dm.order(false)第12題st=[["a","b"],"c"]

st[0][1]='d'

print(len(st),st)

TheresultofrunningtheabovecodeisA2[['a','d'],'c']B3[['d','b'],'c']C2[['d','b'],'c']D3[['a','d'],'c']CreationandUseofTuple第1題Tuplesareimmutableanddonotsupportmethodssuchasinset()andremove()oflistobjects,nordotheysupportthedelcommandtodeleteelementsinthem,butyoucanusethedelcommandtodeletetheentiretupleobject.第2題Pythonlists,tuples,andstringsareallorderedsequences.第3題st=("a","b")st[0]="c"print(st)Theresultoftheprogramis:AErrorB('c','b')C('a','b')D['a','b']第4題Inordertoaddthenumber1toatuple,whichofthefollowingistrueAmyTuple=myTuple+(1,)BmyTuple.append(1)CmyTuple=myTuple+1DmyTuple.insert(0,1)第5題StringsarePythonorderedsequencesand,likelistsandtuples,supportbidirectionalindexing.CreationandUseofDictionary第1題ThefollowingoptionthatcannotbeusedasakeyforadictionaryobjectisA4B(4)C"4"D[4]第2題ThevalueinthedictionaryobjectcanbeAAnyPythonobjectBMutableobjectCImmutableobjectDJuststr,int,andlist第3題deff():

st["name"]="x"

st={"name":"a","sex":"male"}

f()

print(st["name"],st["sex"])

TheresultofrunningtheabovecodeisAxmaleBmaleCamaleDxNone第4題st={"name":"xxx","emails":["a@123.com","b@123.com"],"age":20}

delst["emails"][0]

st["emails"].append("c@123.com")

delst["age"]

print(st)

TheresultofrunningtheabovecodeisA{'name':'xxx','emails':['b@123.com','c@123.com']}B{'name':'xxx','emails':['a@123.com','b@123.com','c@123.com']}C{'name':'xxx','emails':['a@123.com','a@123.com','c@123.com'],"age":20}D{'name':'xxx','emails':['a@123.com','a@123.com','c@123.com']}第5題ThefollowingstatementsthatcannotcreateadictionaryareAdict1={}Bdict2={3:5}Cdict3={[1,2,3]:“uestc”}

Ddict4={(1,2,3):“uestc”}ChineseWordSegmentationModule-jieba第1題jiebaisthebuilt-inChinesewordsegmentationmoduleofpython.第2題ThewordcloudlibrarytreatsthewordcloudasaWordCloudobject,andtheWordCloud()methodintheWordCloudlibraryrepresentsawordcloudcorrespondingtothetext.第3題Thelcut_for_search()methodreturnsavalueofAstringBlistCtupleDdictClassandObject第1題Whenaclassisdefined,thefirstparameterofallinstancemethodsisusedtorepresenttheobjectitself.Thevalueofthisparameterisnotrequiredwhentheinstancemethodiscalledoutsidetheclassbytheobjectname.第2題classStudent:

name="yyy"

age=30

def__init__(self):="xxx"self.age=20

s=Student()

S="zzz"

print(,s.age,S,Student.age)

TheresultofrunningtheabovecodeisAxxx20zzz30Byyy20xxx30Cyyy20zzz30Dxxx20yyy30第3題classStudent:

def__init__(self,n="xxx",s="男"):=nself.sex=s

defshow(self):print(,s.sex)

s=Student("yyy")

Student.show(s)

TheresultofrunningtheabovecodeisAyyy男Bxxx男CStudent.show(s)

ErrorDdef__init__(self,n="xxx",s="男")Error第4題classStudent:name="xxx"age=20

s=Student()

="yyy"

s.age=30

print(,s.age,S,Student.age)

TheresultofrunningtheabovecodeisAyyy30xxx20Byyy30yyy30Cxxx20xxx20DErrorObjectInitialization第1題Classattributesaredirectlydefinedattributeswithinaclass,andtherearetwotypesofattributes:publicclassattributesandprivateclassattributes.第2題Ifyouassignanewvaluetoanexistingclassattributeandaninstanceattribute,boththedefaultvaluefortheclassandthevaluefortheinstancebecomethenewvalue.第3題Classattributescanonlybedefinedatclassdefinitiontime.第4題Thepublicpropertiesdefinedinaclassarecommontoallinstances,sowhenthepublicpropertiesaremodifiedthroughtheclassobject,thecommonpropertiesofeachinstanceobjectwillalsochange.第5題Instancepropertiesaretypicallydefinedinthe__init__()constructorandcanonlybeaccessedbytheinstanceobjectname,nottheclassname.InheritanceandPolymorphism第1題Derivedclassesinheritallthepropertiesandmethodsofthebaseclass.第2題Ifthemethodofthebaseclassdoesnotmeettheneedsofthederivedclass,themethodneedstobeoverridden.Ifamethodofthebaseclassisoverriddeninaderivedclass,themethodinthebaseclassismasked.第3題Thebaseclassconstruct(the__init__()method)isautomaticallycalledininheritance.第4題Whenoverloadingamethodinaderivedclass,ifyouneedtocallamethodwiththesamenameinabaseclass,youneedtocallitbythebaseclassname.第5題Multipleinheritanceiswhenasubclasshastwoormoreparentclasses.Ifthebaseclasshasthesamemethodname,andthebaseclassnameisnotspecifiedwhenusedinasubclass,thePythoninterpreterwillsearchfromlefttoright,executingthefirstmethodofthesamenamefoundintheparentclass.DatetimeModule第1題Thedatetimemoduleislimitedtodatesbetween1970and2038.第2題Whichofthefollowingdoesnotbelongtotheclassdefinedbythedatetimemodule?AdatedeltaBtzinfoCtimedeltaDdatetime第3題Theconstructorfordatetimeis:indatetime.datetime(year,month,day[,hour[,minute[,second[,microsecond[,tzinfo]]]),tzinforepresentsthetimezoneinformation.第4題Thetoday()methodofdatetimereturnsadatetimeobjectrepresentingthecurrentlocaltime,andtheutcnow()methodreturnsadatetimeobjectrepresentingthecurrentutctime.第5題Theontimer()methodintheturtlemoduleisusedtosetthecounter.Thefirstargumentisthenameofthefunctiontobecalled,andthesecondargumentisthetimeinseconds.GUIandtkinterModule第1題Whenyoudesignaformwithtkinter,thepropertiesoftheTextcontroldonotcontainAbg

BfontCbdDcommand第2題Whendesigningaformwithtkinter,thestateoftheButtonisnotincludedAactiveBdisabledCnormalDenabled第3題ThemethodforplacingcontrolscreatedbytkinteronaformisApack

Bshow

CsetDbind第4題Typically,thecontainercontrolusedtocreateasinglelineofinputtextisAEntryBLabelCTextDList第5題CreatesaninstanceoftheButton

andtriggersexecutionofthecallbackfunction,whichshouldbesettothe()propertyoftheinstance.Acommand

Bbind

Cplace

Dcall第6題Whenacontrolislaidoutwiththeplace()method,whichofthefollowingpropertiesdoesnottakeonaformwidthandheightratiobetween0.0and1.0?AxBrelxCrelheightDrelwidthApplicationoftkinterModule第1題InGUIdesign,radiobuttonsareusedtorealizethemutuallyexclusiveselectionofmultipleoptions.Onlyoneoptioncanbeselectedinthesamegroup.Whentheselectionchanges,thepreviouslyselectedoptionautomaticallybecomesinvalid.第2題InGUIdesign,checkboxesareoftenusedtoachievethefunctionofnon-mutuallyexclusivemulti-selection,andtheselectionbetweenmultiplecheckboxesdoesnotaffecteachother.第3題Ingeneral,toreceivesingle,mutuallyexclusiveuserdata,youuseacontrol().ACheckbutton

BRadiobutton

CComboboxDListboxPythonFileOperation第1題defsave():

f=open("test.txt","wt",encoding="utf-8")

f.write("我abc\nxyz")

f.close()

save()

Whichread()functioncanreadeverythingafterexecutingtheabovecode?Adefread():

f=open("test.txt","rt",encoding="utf-8")

forsinf.readlines():print(s,end="")

f.close()Bdefread():

f=open("test.txt","rt")

forsinf.readlines():print

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 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ì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論