版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 走进小学活动方案样本(3篇)
- 二零二五年度二手房交易税费计算合同样本3篇
- 二零二五年度办公大楼智能化系统运维合同2篇
- 2025年度涂料涂料工程招标代理服务合同范本3篇
- 2025年三年级上学期英语教师工作总结范文(2篇)
- 煤矿综掘综合防尘管理制度(3篇)
- 自学书法系统课程设计
- 轮形课程设计
- 二零二五年度个人住房装修贷款保证合同3篇
- 2025年高一班级工作计划(二篇)
- 重庆三峰环境集团股份有限公司招聘笔试题库2024
- 中国式现代化为主题的论文3000字(1) (1)全文
- YB2防爆电机使用说明书
- 安全生产法律法规清单(2024年5月版)
- 江苏省连云港市2023-2024学年八年级下学期期末道德与法治试卷(含答案解析)
- 2024年大学试题(宗教学)-佛教文化笔试考试历年高频考点试题摘选含答案
- 三年级下册语文必背古诗词
- 老年人谵妄中西医结合诊疗专家共识
- 团餐食品安全年度汇报
- 华西解剖学课件绪论和骨学总论
- 2024平安保险测评题库
评论
0/150
提交评论