参考python中英文汇总programming for beginners intermediates_第1页
参考python中英文汇总programming for beginners intermediates_第2页
参考python中英文汇总programming for beginners intermediates_第3页
参考python中英文汇总programming for beginners intermediates_第4页
参考python中英文汇总programming for beginners intermediates_第5页
已阅读5页,还剩146页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

PythonPythonProgrammingforByAdamCopyright©2016byAdamAllrights.Nopartofthispublicationmaybereproduced,distributed,ortransmittedinanyformorbyanymeans,includingphotocopying,recording,orotherelectronicormechanicalmethods,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembodiedincriticalreviewsandcertainother mercialusespermittedbycopyrightlaw.TableofChapter1:LearningAboutPythonTheOriginsofPythonWhyUseChapter2:TheBenefitsandNegativesofPythonTheBenefitsofPythonTheNegativesofChapter3:CommonTermsYouShouldKnowwithPythonChapter4:GettingStartedwithPythonTextEditorChapter5:LearningtheBasicsofPythonProgrammingChapter6:ABitMoreonCommentsChapter7:VariablesandWhatTheyDoinPython欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Gettingstartedincodingcanbetough.Youmayhavelookedatafewofthemostpopularcodinglanguages,suchasC++orJavaandbeenabitscaredbywhatyousaw.Thepagesmayhavebeenfilledtothebrimwithlettersandsymbolsthatyoujustdidn’tunderstand,andyoubecamefrustratedandjustwantedtowalkaway.Manypeoplearescaredofprogramingandfeellikeitisjusttoohardforthem.ButwiththePythonprogramminglanguage,youwillfindthatitcanbeeasierthanevertolearnaboutcodingandtoevenreaditlikeaprofessional.ThisguidebookisgoingtogiveyousomeofthebasicsthatyouneedtogetstartedwithPythonprogramming.WewillstartoutabittalkingaboutwhatPythonprogrammingisaswellassomeofthestepsthatyoushouldtakeinordertodownloadtheprogram,ifitisn’talreadypresentonyourcomputer,andgiveyousomemoreinformationtoreallyunderstandwhythisprogramissogreat.Wewillthenmoveontosome thatwillbeusefultoyouwhenstartingoutwiththeprogramandeventalkaboutthebenefitsandthedrawbacksofusingPythonforallyourcodingandprogramingneeds.Therestoftheguidebookisdevotedtotalkingaboutsomeofthe欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍thingsthatyoucandowithinthePythonprogramaswellassomeexamplesofhoweachofthesewouldwork.Wetalkaboutaddingcommentsintothecode,workingwithstringsandintegers,andevenspendsometimeworkingwithvariablessothattheywillshowuprightintheprogram.Itisagreatideatoexperimentabitwiththeprocess.PythonmakesiteasytotestoutyourstringssothatyoucanfigureoutwhatisgoingtoworkandwhatneedssomemoreGettingstartedinprogramingcanseemlikeachallenge.Youmayworrythatyouaren’tgoingtobeabletofigureitalloutandallofthosecrazyprograminglanguagesmayhavescaredyouawayinthefirstplace.ThisguidebookisgoingtospendsometimelookingatthePythonlanguageandexploringhoweasyitcanbetogetstartedwiththissimpleprogram.欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Chapter1:LearningAboutThecomputerworldhasbroughtinmanydifferenttypesofpeople.Someareinterestedinmakingmoneycreatingtheirownprogramstoselltoothers.Somejustliketomessaroundandlearndifferentthingsabouthowthecomputerwillwork.Andstillothershavedevotedtheirlivestoprogramming,makingittheproductthatbringshometheir eeachmonthwhethertheyworkatrepairingcomputers,workinacorporationtokeepthecomputerssafe,or someotheraspectofcomputertechnology.Whenitcomestocomputertechnology,nothingisgoingtobesimple.Beforeyoucanevengetaprogramtoworkonthecomputer,itneedstoreceivetherightcodetomakeitwork.ThereareseveraloptionsforcodecreationthatcomputertechcanchooseincludingJava,C++andPython.Herewe欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍exploreabitaboutPythonandwhyitisoftenpreferredovertheothertwoprogrammingoptions.BeforeyouareabletostartusingPythontotakeoveryourprogrammingneeds,itisimportanttostartlearningmoreaboutitandallofthegreatbenefitsyouwillreceivewhenusingthisprogram.Pythonisahighlevelprogrammingtool,whichmeansthatitiseasytouseandread,evenasabeginner.Thephilosophybehindthecodeisreadabilityandithasatypeofsyntaxthatallowstheprogrammertoexpresstheirconceptswithouthavingpagesofcodealongwithit.Comparedtousingotherpopularcodes,likeJavaandC++,thiscanmakePythonmucheasiertocomplete.Thephilosophyofthiscodelanguageissimpleenoughtouse.Itbelievesthatasimpledesignissomuchbetterthanacomplexoneandthatreadabilityisimportant.Thisisagreatlanguageforbeginnerstogetstartedonbecausetheywillactuallybeabletoreadandunderstandthecodetheyareputtingin.Withotheroptions,theymayhavetospendalotoftimetryingtogetthecodejustright,addinginmanyothersymbolstogetittowork.ButwithPython,itiskeptmuchsimplerandyoumayfindthatitiseasiertoreadthroughthelinesandseewhatyouare SomeofthefeaturesthatyoumaylikewithPython欢迎加入 Python编程学习交 ,群里免费提供500+本Python书籍Anelegantsyntaxwhichwillmaketheprogramssoeasytoread.Languagethatiseasytousesothattheprogramwillworkwithoutalotofbugs.Ifyouare ngadhocprogrammingtasksorprototypedevelopmentbecauseitworkswellwithoutissueswithmaintainingtheHasalargelibrarythatwillworkwithotherprogrammingtaskssuchaschangingfiles,searchingfortext,andconnectingwithwebservers.Pythonisreallyinteractive.Thismakesiteasierforyoutotestoutsmallbitsofcodetoseeiftheywork.YoucanalsobundleitwithadevelopmentenvironmentcalledIDLE.Ifyouwouldliketoexpandtheprogramminglanguage,itiseasytoextendintoothermoduleslikeCorC++.Windows,andMacOSX.Thesoftwareisfree.Youwon’thavetopayanythingtodownloadandusePythoninyourownlife.youcanalsomakemodificationsandredistributethisproduct.Itisunderalicense,butitisanopensourcelicensesoothersareabletouseit.EventhoughPythonisasimpleprogramminglanguage,itdoescontainsomeadvancedfeatureslikelistcomprehensionsandgenerators.Errorscanbecaughtquicklyinthisprogramming.Sincedatatypesdynamicallytyped,whenyoumixtypestogetherthatdon’tmatch,it欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍raiseanexceptionforyoutoYoucangroupthecodesintopackagesandmodulesifneeded.Thereisawidevarietyofbasicdatatypesthatyoucanchoosefromincludingdictionaries,lists,strings,andnumbers.TheOriginsofThebeginningofthemodernPythonprogrammingstartedinDecemberof1989.ThecreatorofthisprogramwasGuidovanRossumwhobeganprogrammingasmoreofahobby.Atthetime,vanRossumwasworkingonaprojectwiththeDutchCWIresearchinstitute,thatwaslaterterminated.VanRossumwasabletousesomeofthebasicsofthisnewlanguage,knownastheABClanguage,inordertoworkonPython.Themainstrengthofthislanguageisthatitisreallyeasytoextendupontomakemorecomplex,orkeepsimple,anditwasabletosupportmultipleplatforms.Bothofthesewereimportantduringthedayswhen computerswere ingpopular.AndsincePythonwasdesignedtocommunicatewithdifferentfileformatsandlibraries,itbecameahitaswell.Pythonhasgrownquiteabitsinceitsinceptionandmoretoolshave欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍easytouse,vanRossumhasbeenworkingoninitiativesthatencouragetheeducationofcodingtoeveryone,notjustaselectfew.UsingPythontousecodingcanmakethingseasierandhelpstogetridofsomeofthefearsassociatedwiththecomplexcomputercodessinceitdoesn’tlooksoscary.Overtheyears,vanRossumdecidedtomakePythonopensourced.ThisallowedalltogainaccessandmakechangestoPythonsothatifsomethinghappenedtovanRossum,allwouldnotbelost.ThankstohavingPythonopensourced,Python2.0wasreleasedduring2000tomakeitmorecommunityorientedandtohaveatransparentdevelopmentprocess.ThereareafewnewerversionsofPython2.0stillbeingused,butPython3hasbeentakingtheworldbystormandmostanticipatethiswillbethenormaloneusedwithinthenextfewyears.PythonThisversionofPythonwasreleasedin2008.Itisnotsimplyanupdatetotheprogram,butacompletechangeinit.Whiletherearealotofgreatfeaturesthatcomewiththisversion,itdoesn’thaveabackwardcompatibilitysoyouwillhavetomakeachoicebetweenPython2.0andPython3.Tomakethingseasier,theprogrammersdidmakealittlemarkerwithintheprogramthatwouldshowacoderwhatneededtobechangedbetweenthetwoprograms欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍uploading.Despitethis,mosthavestuckwithPython2.0forWhyUseAsyoucanprobablyguess,thereareseveraldifferentcomputercodingprogramsthatyoucanchoosetouse.Butwhiletherearesomebenefitstousingtheseotherprograms,Pythonisoneofthebestoptionsoutthere.Itiseasytouse,hasalotofoptionsforyoutochoosefrom,anditcanevenbeusedoveravarietyofplatformswithouthavingtochangethingsup.SomeofthebenefitsthatyouwilllovewithPythoninclude:PythonisdesignedtoworkwiththeEnglishlanguage,makingiteasytoread.Therearealsostrictrulesintermsofpunctuationontheprogramsoyouaren’tjustlookingatbracketsallovertheplace.Pythonalsomakessurethattheprogrammerknowshowtoformateverythingthankstoasetofrulesthatareinplace,makingiteasyforeveryonetocreateacodethatotherscanfollow.欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Pythonhasbeenaroundforover25yearsnowandsinceitisoneoftheeasiestcodestolearnhowtouse,therehavebeenquiteafewdifferentcodeswrittenusingthesystem.Thegoodnewsisthatthissystemisopensourcedsothatthecodeisavailableforanyprogrammertouse.YoucaninstallthePythonprograminyourownsystemanduseitforyourown aluse.Whetheryouareusingthecodestofinishoffaproductortowritesomeofyourowncodes,thelibraryofPythoniseasytouse.Thecodesthatyouwantwillbeinstalledintothelibrariesandsincetheprogramhasbeenaroundforalongtie,theyaregoingtocoverprettymuchwhateveryouwantfromautomatingyourservertomakingchangestoapicture.SincePythonissopopular,thecommunityforPythonisprettybig.Thereareconferenceswithlotsofnetworkingandworkshopsavailableforthisprogrammingproductsandlotsofplacesyoucanvisit,bothonlineandoffline,toaskquestionsortolearnmoreabouttheprogram.YoumaywanttoconsidercheckingoutafewoftheseplacesifyouareabeginnerwithPythonasitcanhelpyoutolearnmoreandeventomeetsomenewpeople.Ifyouareinterestedingettingstartedwithcoding,Pythonisoneoftheoptionsthatyoucanmake.Itissimpletogetstartedonandsinceitwill欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍onavarietyofdifferentplatforms,itissuretoworkonyour computer.Sinceitiseasytoread,youwillfindthatcodingdoesn’thavetobeachallengeandyoucancreateyourown,orlearnfromothersinnotime.欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Chapter2:TheBenefitsandNegativesofPythonisagreatprogramtousewhetheryouareabeginnerintheprogrammingworldoryouhavebeenintoitforsometime.ManyofthosewhoarejustlookingatgettingstartedwithprogrammingwilljumprightinwithPythonandmakeittheirown.Itissimpletounderstandandcanbeusedbyanyonewhoisreadytogetstartedwithcoding.Thischapterisgoingtotakesometimetoexplainsomeofthepositives,aswellassomeofthedrawbacks,ofusingPythonforyourprogramminglanguage.TheBenefitsofPythonisprobablyoneofthebestprogramminglanguagesthatyoucantouse.Beginnersaregoingtolovehoweasyitistoturnonthisprogram欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍startwritingtheirowncodes,evenwithoutexperience,andthereisplentytoenjoywhenyouareaprofessional,oranexpert,aswell.SomeofthebenefitsthatyouwillgetwhenyougetstartedwithPythoninclude:EasytouseandWhenitcomestoprogramminglanguage,therearenonethatareaseasytouseasPython.Otherlanguagesarekindofclunkyandhardtolookat.Youmaytakealookatthemandnoticethattheyhavetonsofbracketsandevenwordsthatyouwon’tevenrecognize.Itisenoughtoscareawaysomeonewhoisn’tusedtoprogrammingatalljustbecauseallthewordslookabitintimidating.Pythonisabitdifferent.Insteadofallthecrazybrackets,itmakesuseofindentations,causinganeasiertoreadpagethatisn’tsuchamess.Insteadofwordsthatyoucan’tunderstand,itusesEnglish.Theotherspecialcharactersarekepttoaminimumsothatyoucanlookatthepageofcodeandnotfeellikeyouaregoingtobeoverwhelmedintheprocess.Thisisoneoftheeasiestprogrammingtoolsthatyoucanuse.Itlooksnicethepageandwilluseplentyofwhitespaces,whenitcan,tomakeiteasier欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍readwhatyoushouldknow.Therearealsoplentyofplaceswithcommentssoyoucangetclarificationifaprogramistooconfusingforyou.Overall,itisoneofthebestprogramminglanguagestousetoreallygetaheadoreventolearnaboutprogramming.UsesEnglishasthemainSinceEnglishisthelanguagethatthisprogramisbasedoff,itisreallyeasytoread.Therearen’talotofwordsthatyouwon’tgetandyouwon’thavetospendtimetryingtofigureoutwhatitis lingyou.TheprogramisallinEnglishandyouwilllovehowsimplethiscanmakethings.AlreadypresentonsomeInsomecases,Pythonisalreadypresentonyourcomputer.MacOSXsystemsaswellasthosewithUbuntuwillalreadyhavePythonpreloaded.Youwillsimplyneedtodownloadatextinterpretertogetstarted.IntermsofusingPythononWindowscomputers,allyouneedtodoisdownloadtheprogram.Pythonworkswithalloftheseprograms,evenifitisn’tinstalledrightfromthe欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍CanworkwithotherprogrammingInthebeginning,youwillmostlikelyonlyusePythononitsown.Itisagreatprogramtolearnwithandgrowwith.Butovertime,youmaydecidethatyouwanttotrysomethingnewthatPythoncan’tdoonitsown.Luckily,Pythonisabletoworkwithseveralotherprogramminglanguages,suchasC++andJavaScript,soyoucanmessaround,learnsomemore,andreallygetthecodethatyouarelookingfor,evenifPythonisnotabletodoallthework.CantestoutthingswiththeWhenyoudownloadPython,youaregoingtohavetodownloadatextinterpretertoo.ThiswillmakeiteasierforPythontoreadthroughyourinformation.Youcanusesimpleproductsthataresometimesalreadyonyourcomputer,suchasNotepadfromWindowsorlookforanotherinterpreterthatmaybeabiteasier.Onceyoupickouttheinterpreterthatyouwouldliketouse,itistimetogettoworkwritingthecode.Someofthosewhoarenewtocodingmayfeelabouttryingtogetthecodetowork.ThisisanotherspotwherePython欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍makethingseasier.Itwillbeabletotakethewordsthatyouaretyandspitthembackout,withthehelpoftheinterpreter,injustafewseconds.Youcantestwhatyouare ngwhileyouareworkingonit!TherearesomanybenefitsofusingthePythonprogram.Beginnersaregoingtolovehowreadilyavailablethisprogramisandhoweasyitistolearnsomeofthesimplecommandsinnotime.Eventhosewhohavebeenprogrammingforsometimewillbeimpressedbyhowthisallworks!TheNegativesofWhiletherearealotofreasonstolovePython,itisimportanttorealizethatthereareafewnegativesthatyoushouldwatchoutfor.ThesenegativesItdoesn’thavealotofForthosewhoarelookingtoworkwithaprogramthathasalotofspeed,Pythonmaynotalwaysbethebestoptionforyou.Itisaninterpretedlanguagesothiswillslowitdowncomparedtosomeoftheotheroptionsthatarecompiledlanguages.However,itdoesdependonwhatyouare欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Therearecertainben arkswiththePythoncodethatcanrunfasterusingPyPycomparedtoothercodes.LuckilythisissuewithaslowspeedandPythonisbeingremedied.ProgrammersareworkingtomaketheinterpretingspeedofPythonfastersothatyouwon’thavetocompareitwiththeotherssomuch.Overtime,thehopeisthatPythonwillbeabletoworkatthesamespeedasCandC++orevensomeofthenewerprogramminglanguagesthatarecomingout.NotpresentonmostmobilePythonisagreatoptiontouseifyouhavearegularcomputer.Itisavailableonmanydesktopandserverplatformstohelpyoucreatethecodethatyouarelookingfor.Butitisnotreadytogointomobilecomputing.Sincethereissuchabigincreaseinrevenueandpeoplegoingintothemobileindustry,itissadthatthisprogramminglanguagehasn’tkeptupwiththetrendslikeothers.PerhapsinthefuturePythonwilldecidetogointothefutureanddevelopaversionthatwillbeabletoworkwellwithvariousmobiledevices.Untilthen,programmerswillhavetobesatisfiedwithusingitontheirdesktopand欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍RestrictionswiththeIfyouarelookingtoworkwithaprogramthathasalotofdesignoptions,thePythonprogrammaynotbetherightoptionforyou.Thedesignlanguageisnotuptowhatyouwillfindwithsomeoftheotheroption.Sinceyouareworkingwithaprogramthatisdynamicallytyped,ittakesmoretestingandcanhavemoreerrorsthatwillonlyshowupwhenyouarerunningtheprogram.TheglobalinterpreterlockmeansthatyoucanonlyhaveonethreadaccesstheinternalsofPythonatatime.Thismaynotbeasimportantanymoresinceitiseasytospawnthetasksouttodifferentprocesses,butthedesignisnotasniceassomeoftheotheroptionsthatyouwouldlike.AgoodwaytoworkwiththedesignistorememberthatindentationisimportantwithPython.Otherprogramminglanguagesaregoingtousealotofbracketstoshowthedifferenceinlinesandinformationinsidetheprogram,butPythonisgoingtorelyonindentations.Makesuretobecarefulwithusingthistoavoidissuesanderrorsthatcancomeup.Pythoncanbeoneofthebestprogramsthatyouusetowriteyourown欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍andhavesomefun.Whiletherearealotofbenefitstousingthisprogram,especiallycomparedtosomeoftheotheronesthataren’taseasytoread,itisimportanttounderstandboththepositivesandnegativesofeachoptionbeforeyoujumpin!欢迎加入 Python编程学习交 ,群里免费提供500+本Python书籍Chapter3:CommonTermsYouShouldKnowwithBeforeyougettoofarintoyourprogrammingwithPython,itisimportanttounderstandsomeofthewordsthatcanmaketheprogrammingeasiertounderstand.ThischapterisgoingtotakesometimetolookatthedifferentwordsthatarecommoninPythonprogramming,andwhichwedotalkaboutabitinthisguidebook,tohelpavoidsomeconfusionandtohelpyougetstartedwithyourfirstcode.Class—thisisatemplatethatwasusedforcreatinguser-definedobjects.Docstring—thisisastringthatwillappearlexicallyfirstexpressioninsideamodule,function,orclassdefinition.Theobjectwillbeavailableto ationtools.Function—thisisablockofcodethatisinvokedwhenusingaprogram.Itisbestusedinordertoprovideacalculationor欢迎加入 Python编程学习交 ,群里免费提供500+本Python书籍autonomousThisisthebasicinterpreterandeditorenvironmentthatyoucanusealongwithPython.Itisgoodforthosewhoarejustbeginningwiththisandcanworkforthoseonabudget.Itisaclearexampleofcodeandwon’twastealotoftimeorspace.Immutable—thisisanobjectwithinthecodethatisassignedafixedvalue.Thiscouldincludetuples,strings,andnumbers.Youcan’taltertheobjectandyouwillneedtocreateanewobjectwithadifferentvalueandstoreitfirst.Thiscanbehelpfulinsomecases,suchasthekeysinaInteractive—onethingthatalotofbeginnerslikeaboutPythonisthatitissointeractive.Youcantryoutsomedifferentthingsintheinterpreterandseehowtheywillreactrightawayintheresults.Itisagoodwaytoimproveyourprogrammingskills,testoutanewideayouhaveandList—thisisadatatypewithinPythonthatisbuiltin.Itcontainsamutablesequenceofvaluesthataresorted.Itcanincludeimmutablevaluesofnumbersandstringsaswell.Mutable—thesearetheobjectsthatwillbeabletochangetheirvaluewithintheprogram,butwhichareabletokeeptheiroriginalid().Object—withinPython,thisisanydatawithastate,suchasavalueanattribute,aswellasadefinedbehavior,ora欢迎加入 Python编程学习交 ,群里免费提供500+本Python书籍Python3000—Python2andPython3arethemaintwotypesofPythonthatareavailable.ManypeoplehavestuckwithPython2sincePython3doesnothaveanybackwardscapabilitiesandtheylikeusingthedatabasesontheolderversion.Python3000isamythicaloptionofPythonthatdoesallowthisbackwardcapabilitysoyoucanuseitandthePython2.String—thisisoneofthemostbasictypesthatyouwillfindinPythonthatwillstorethetext.InPython2,thestringswillstoretextsothatthestringtypecanthenbeusedtoholdontobinarydata.Triplequotedstring—thisisastringthathasthreeinstancesofeitherthesinglequoteorthedoublequote.Itcouldhavesomethinglike‘’Ilovetacos’.Theyareusedformanyreasons.Theycanhelpyoutohavedoubleandsinglequotesinastringandtheymakeiteasiertogooverafewlinesofcodewithoutissues.Tuple—thisisadatatypethathasbeenbuiltintoPython.Thisdatatypeisanimmutableorderedsequenceofvalues.Thesequenceistheonlypartthatisimmutable.Itcancontainsomemutablevalues,suchashavingadictionaryinsideit,wherethevalue’scanchange.Type—thisisacategoryorsortofdatathatisrepresentedintheprogramminglanguages.Thesetypesaregoingtodifferintheirproperties,theyincludingimmutableandmutableoptions,aswellasintheirfunctionsandmethods.Pythonincludesafewoftheseincludingdictionarytypes,tuple,list,floatingpoint,long,integer,and欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍Chapter4:GettingStartedwithNowthatweknowsomeofthebenefitsofchoosingthisprogram,itistimetogetstartedwithit.Beforeyouareabletolearnsomeofthegreatstepsthatareneededtomakethisprogramcreatecodeforyou,itistimetosetuptheenvironment.ForthosewhohaveacomputerwithMacOSXorUbuntu,youwillalreadyhavePythoninstalledonthesystemThiscanmakethingseasiertogetstartedasyouwilljustneedtoclickontheicontogetstarted.WindowscomputerswillneedtoinstallPython.WhilePythonworksjustfineonWindowscomputers,itdoesn’tcomepreinstalledsoyouwillneedtodothis.ThefollowingstepsworkforWindows7to10:DownloadPython—youcanchoosebetweenPython2orPython3.Botharefantasticoptions;itjustdependsonwhichonewillgetthejobdonefor欢迎加入 Python编程学习交 ,群里免费提供500+本Python书籍ClicktorunthePythonInstaller.Whenyougettotheoptions,choosetoCustomizeInstallation.Youwillseeaboxpopup.ClickoneveryboxthatisunderOptionalFeaturesandthencontinue.Onthenextscreen,lookfortheAdvancedOptionsandthenchoosewhereyouwouldliketohavePythoninstall.Onceyouhavegottenthisfar,thenextpartistosetupyourPATHvariable.Thisisgoingtoallowtheusertoincludedirectoriesforallthecomponentsandpackagesthatareneeded.Todothisstep:OpenuptheControlPanelontheWindowscomputer.LookupEnvironment.UnderSystemEnvironmentVariable,clickonEdit.ThenclickonEnvironmentVariables.Youmayhavetolookabitforthenextpart,butlookforUserVariables.Youcantheneithercreateanewoneoreditanexistingpath.Tocreateanewpath,selectPATHasthenameandaddittothedirectoriesthatarethere.MakesurethateachVariableValuesisseparatedwithasemicolon.Ifyouwanttoedityourexistingpath,youneedtomakesureeachvalueisonadifferentline.ClickonNewandthenput欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍directoriesondifferentNowyoucanopenyourcommandprompt.TodothisclickonStartthenWindowsSystemandthenCommandPrompt.Whenthecommandpromptopens,youcantypein“Python.”ThiswillloadupthePythoninterpreter.YoucanthentypeinExitandhitEntertogetbacktothecommandprompt.YouwillnotbeabletoprogramPythonwithouthavingthetexteditorinplaceonyourcomputer.IfyouareusingWindows,theNotepadfunctionwillwork.MakesurethatyouarenotusingWordthough,itisnotconsideredaneditorandyourcodeisnotgoingtosaveonthesystemproperly.IfyouareconsideringgettingaversionofNotepad,youwillnoticethatNotepad++isthebestonetouseonaWindowscomputerandTextWrangleristhebesttouseforMac.Tosetthemup,dothefollowing:DownloadandtheninstallNotepadOnceitisdownloaded,openupthesettingsandclickon Tab

欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍TicktheboxthatisbesideExpandTabsMakesurethatthevalueisat4.ClickagaintoDownloadandtheninstallTextYouwon’tneedtoregistertoinstallthesoftware,justclickCancelifthereisaboxthatcomesupaskingforthis.Otherwise,followtheotherinstructionsthatcomeonthescreentosetthiseditorup.OncetheprogramisonyourcomputeritistimetolearnmoreaboutthecodingandfunctionsthatyoucanenjoyonPython.WhileyouaresettingupPython,makesurethatyoudownloadtheIDLEor欢迎加入非Python编程学习交 ,群里免费提供500+本Python书籍IntegratedDevelopmentandLearningEnvironment.ThisshoulddownloadalongwithPythonifyouaresettingitup,butmakesuretocheckintothiswhileyouaregoingthroughtheprocess.ThisistheenvironmentthatyouaregoingtoworkwithwhenyouareonPythonanditcanmakethingseasy.Ifyoudon’twanttomessaroundwithfindinganotherenvironmentoryouwanttomaketheprocessaseasyaspossibleforyouasabeginner,thisistheoptionforyou.Integrateddebuggerwithpersistentbreakpoints,callstackvisibility,andsteptomakethingseasierPython andcompletingthecode.Now,youcanchoosetouseanotherenvironment,likethosethatwediscussedaboveifneeded,butsincethisoneoftencomesasanoptionwithPythonanditisdesignedtoworkwellwiththissystem,therearemanypeoplewhochoosetogowiththisoption.Thatbeingsaid,therehavebeensomeissuesinthepastwithIDLEhavingtroublefocusing,won’tcopysomethings,andsomeclientsdon’tliketheinterfacedesign.Youmaywanttotryoutthisprogramaheadtimeandseeifitistherightoneforyouorifyouwouldliketouseoneoftheoptionsabove.GettingPythonsetuponyourcomputerisaprettyeasyprocess.Therearealreadyseveraltypesofcomputersthathavetheprogramminglanguagealreadypresentsoyouwon’thavetodoanyworkandtherestofthemsimplyneedaquickdownloadtocomplete.YoucanwaitjustashortamountoftimetogetPythononyourcomputerandthenyouaregoodtogoandtryoutsomeofthecodesyouwanttomake.Chapter5:LearningtheBasicsofPythonNowitistimetogettoknowabitmoreaboutPythonprogrammingandhowyoucanmakeitworkforyou.Youwillneedtolearnabitmoreaboutthe andthevariablesthatcomewithPythonsoyouareabletowritethewordsthatyouwantandmaketheprogramperforminacertainway.Let’stakealookatsomeofthesebasicsofPythonprogrammingsoyoucangetstartedwithyournewcoderightaway.Whenyouareworkingonanewcomputercodingprogram,youaregoingtonoticethateachcomputerlanguagewillhavecertain .Thesearethewordsthataremeantforaspecificcommandorpurposeinthelanguageandyoushouldtrytoavoidusingthemanywhereelse.Ifyoudousethesewordsinotherpartsofyourcode,youmayendupwithanerroralertortheprogramnotworkingproperly.The thatare forPythoninclude:IdentifierWhenyouarecreatinganewprograminPython,youaregoingtoworkoncreatingquiteafewentities,acombinationoffunctions,classes,andvariables.Allothesewillbegivenanamethatisalsoknownasanidentifier.ThereareafewrulesthatyouneedtofollowwhenforminganidentifierinPythonItshouldcontainletters,eitheruppercaseorlowercaseoraofthetwo,numbers,andtheunderscore.YoushouldnotseeanyspacesTheidentifiercan’tstartwithaTheidentifiercan’tbeakeywordanditshouldn’tincludeoneoftheIfyoubreakoneoftheserules,theprogramwillcloseonyouandwillshowasyntaxerror.Inaddition,youneedtoworkonmakingidentifi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论