版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第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错误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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 黑龙江省龙江教育联盟2026届高三上学期期末考试生物试卷(含答案)
- 广东省深圳市深圳实验学校2025-2026学年上学期期末七年级数学试卷(无答案)
- 2025-2026学年北京市朝阳区八年级(上)期末道德与法治试卷(含答案)
- 五宫数独题目及答案
- 初中数学知识梳理课件
- 吉林省四平市伊通满族自治县2025-2026学年八年级上学期期末考试地理试题(原卷版+解析版)
- 涉密测绘外业安全保密管理制度
- 防火卷帘控制技术要领
- 冀教版二年级下册数学第六单元-三位数加减三位数-同步练习题带答案(新)
- 施工员招聘考试及答案
- 食品代加工业务合同样本(版)
- 车间管理人员绩效考核方案
- 安全生产应急平台体系及专业应急救援队伍建设项目可行性研究报告
- 浙江省杭州市北斗联盟2024-2025学年高二上学期期中联考地理试题 含解析
- 医用化学知到智慧树章节测试课后答案2024年秋山东第一医科大学
- 中国传统美食饺子历史起源民俗象征意义介绍课件
- 医疗器械样品检验管理制度
- 更换法人三方免责协议书范文
- 中建“大商务”管理实施方案
- 民用无人机操控员执照(CAAC)考试复习重点题库500题(含答案)
- 《动画分镜设计》课件-第二章:镜头基本知识
评论
0/150
提交评论