版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
PythonPythonProgrammingforByAdamCopyright?2016byAdamAllrights.Nopartofthispublicationmaybereproduced,distributed,ortransmittedinanyformorbyanymeans,includingphotocopying,recording,orotherelectronicormechanicalmethods,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembodiedincriticalreviewsandcertainother mercialusespermittedbycopyrightlaw.TableofChapter1:LearningAboutPythonTheOriginsofPythonWhyUseChapter2:TheBenefitsandNegativesofPythonTheBenefitsofPythonTheNegativesofChapter3:CommonTermsYouShouldKnowwithPythonChapter4:GettingStartedwithPythonTextEditorChapter5:LearningtheBasicsofPythonProgrammingChapter6:ABitMoreonCommentsChapter7:VariablesandWhatTheyDoinPython歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Gettingstartedincodingcanbetough.Youmayhavelookedatafewofthemostpopularcodinglanguages,suchasC++orJavaandbeenabitscaredbywhatyousaw.Thepagesmayhavebeenfilledtothebrimwithlettersandsymbolsthatyoujustdidn’tunderstand,andyoubecamefrustratedandjustwantedtowalkaway.Manypeoplearescaredofprogramingandfeellikeitisjusttoohardforthem.ButwiththePythonprogramminglanguage,youwillfindthatitcanbeeasierthanevertolearnaboutcodingandtoevenreaditlikeaprofessional.ThisguidebookisgoingtogiveyousomeofthebasicsthatyouneedtogetstartedwithPythonprogramming.WewillstartoutabittalkingaboutwhatPythonprogrammingisaswellassomeofthestepsthatyoushouldtakeinordertodownloadtheprogram,ifitisn’talreadypresentonyourcomputer,andgiveyousomemoreinformationtoreallyunderstandwhythisprogramissogreat.Wewillthenmoveontosome thatwillbeusefultoyouwhenstartingoutwiththeprogramandeventalkaboutthebenefitsandthedrawbacksofusingPythonforallyourcodingandprogramingneeds.Therestoftheguidebookisdevotedtotalkingaboutsomeofthe歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍thingsthatyoucandowithinthePythonprogramaswellassomeexamplesofhoweachofthesewouldwork.Wetalkaboutaddingcommentsintothecode,workingwithstringsandintegers,andevenspendsometimeworkingwithvariablessothattheywillshowuprightintheprogram.Itisagreatideatoexperimentabitwiththeprocess.PythonmakesiteasytotestoutyourstringssothatyoucanfigureoutwhatisgoingtoworkandwhatneedssomemoreGettingstartedinprogramingcanseemlikeachallenge.Youmayworrythatyouaren’tgoingtobeabletofigureitalloutandallofthosecrazyprograminglanguagesmayhavescaredyouawayinthefirstplace.ThisguidebookisgoingtospendsometimelookingatthePythonlanguageandexploringhoweasyitcanbetogetstartedwiththissimpleprogram.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Chapter1:LearningAboutThecomputerworldhasbroughtinmanydifferenttypesofpeople.Someareinterestedinmakingmoneycreatingtheirownprogramstoselltoothers.Somejustliketomessaroundandlearndifferentthingsabouthowthecomputerwillwork.Andstillothershavedevotedtheirlivestoprogramming,makingittheproductthatbringshometheir eeachmonthwhethertheyworkatrepairingcomputers,workinacorporationtokeepthecomputerssafe,or someotheraspectofcomputertechnology.Whenitcomestocomputertechnology,nothingisgoingtobesimple.Beforeyoucanevengetaprogramtoworkonthecomputer,itneedstoreceivetherightcodetomakeitwork.ThereareseveraloptionsforcodecreationthatcomputertechcanchooseincludingJava,C++andPython.Herewe歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍exploreabitaboutPythonandwhyitisoftenpreferredovertheothertwoprogrammingoptions.BeforeyouareabletostartusingPythontotakeoveryourprogrammingneeds,itisimportanttostartlearningmoreaboutitandallofthegreatbenefitsyouwillreceivewhenusingthisprogram.Pythonisahighlevelprogrammingtool,whichmeansthatitiseasytouseandread,evenasabeginner.Thephilosophybehindthecodeisreadabilityandithasatypeofsyntaxthatallowstheprogrammertoexpresstheirconceptswithouthavingpagesofcodealongwithit.Comparedtousingotherpopularcodes,likeJavaandC++,thiscanmakePythonmucheasiertocomplete.Thephilosophyofthiscodelanguageissimpleenoughtouse.Itbelievesthatasimpledesignissomuchbetterthanacomplexoneandthatreadabilityisimportant.Thisisagreatlanguageforbeginnerstogetstartedonbecausetheywillactuallybeabletoreadandunderstandthecodetheyareputtingin.Withotheroptions,theymayhavetospendalotoftimetryingtogetthecodejustright,addinginmanyothersymbolstogetittowork.ButwithPython,itiskeptmuchsimplerandyoumayfindthatitiseasiertoreadthroughthelinesandseewhatyouare SomeofthefeaturesthatyoumaylikewithPython歡迎加入 Python編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍uploading.Despitethis,mosthavestuckwithPython2.0forWhyUseAsyoucanprobablyguess,thereareseveraldifferentcomputercodingprogramsthatyoucanchoosetouse.Butwhiletherearesomebenefitstousingtheseotherprograms,Pythonisoneofthebestoptionsoutthere.Itiseasytouse,hasalotofoptionsforyoutochoosefrom,anditcanevenbeusedoveravarietyofplatformswithouthavingtochangethingsup.SomeofthebenefitsthatyouwilllovewithPythoninclude:PythonisdesignedtoworkwiththeEnglishlanguage,makingiteasytoread.Therearealsostrictrulesintermsofpunctuationontheprogramsoyouaren’tjustlookingatbracketsallovertheplace.Pythonalsomakessurethattheprogrammerknowshowtoformateverythingthankstoasetofrulesthatareinplace,makingiteasyforeveryonetocreateacodethatotherscanfollow.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Pythonhasbeenaroundforover25yearsnowandsinceitisoneoftheeasiestcodestolearnhowtouse,therehavebeenquiteafewdifferentcodeswrittenusingthesystem.Thegoodnewsisthatthissystemisopensourcedsothatthecodeisavailableforanyprogrammertouse.YoucaninstallthePythonprograminyourownsystemanduseitforyourown aluse.Whetheryouareusingthecodestofinishoffaproductortowritesomeofyourowncodes,thelibraryofPythoniseasytouse.Thecodesthatyouwantwillbeinstalledintothelibrariesandsincetheprogramhasbeenaroundforalongtie,theyaregoingtocoverprettymuchwhateveryouwantfromautomatingyourservertomakingchangestoapicture.SincePythonissopopular,thecommunityforPythonisprettybig.Thereareconferenceswithlotsofnetworkingandworkshopsavailableforthisprogrammingproductsandlotsofplacesyoucanvisit,bothonlineandoffline,toaskquestionsortolearnmoreabouttheprogram.YoumaywanttoconsidercheckingoutafewoftheseplacesifyouareabeginnerwithPythonasitcanhelpyoutolearnmoreandeventomeetsomenewpeople.Ifyouareinterestedingettingstartedwithcoding,Pythonisoneoftheoptionsthatyoucanmake.Itissimpletogetstartedonandsinceitwill歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍onavarietyofdifferentplatforms,itissuretoworkonyour computer.Sinceitiseasytoread,youwillfindthatcodingdoesn’thavetobeachallengeandyoucancreateyourown,orlearnfromothersinnotime.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Chapter2:TheBenefitsandNegativesofPythonisagreatprogramtousewhetheryouareabeginnerintheprogrammingworldoryouhavebeenintoitforsometime.ManyofthosewhoarejustlookingatgettingstartedwithprogrammingwilljumprightinwithPythonandmakeittheirown.Itissimpletounderstandandcanbeusedbyanyonewhoisreadytogetstartedwithcoding.Thischapterisgoingtotakesometimetoexplainsomeofthepositives,aswellassomeofthedrawbacks,ofusingPythonforyourprogramminglanguage.TheBenefitsofPythonisprobablyoneofthebestprogramminglanguagesthatyoucantouse.Beginnersaregoingtolovehoweasyitistoturnonthisprogram歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍readwhatyoushouldknow.Therearealsoplentyofplaceswithcommentssoyoucangetclarificationifaprogramistooconfusingforyou.Overall,itisoneofthebestprogramminglanguagestousetoreallygetaheadoreventolearnaboutprogramming.UsesEnglishasthemainSinceEnglishisthelanguagethatthisprogramisbasedoff,itisreallyeasytoread.Therearen’talotofwordsthatyouwon’tgetandyouwon’thavetospendtimetryingtofigureoutwhatitis lingyou.TheprogramisallinEnglishandyouwilllovehowsimplethiscanmakethings.AlreadypresentonsomeInsomecases,Pythonisalreadypresentonyourcomputer.MacOSXsystemsaswellasthosewithUbuntuwillalreadyhavePythonpreloaded.Youwillsimplyneedtodownloadatextinterpretertogetstarted.IntermsofusingPythononWindowscomputers,allyouneedtodoisdownloadtheprogram.Pythonworkswithalloftheseprograms,evenifitisn’tinstalledrightfromthe歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍makethingseasier.Itwillbeabletotakethewordsthatyouaretyandspitthembackout,withthehelpoftheinterpreter,injustafewseconds.Youcantestwhatyouare ngwhileyouareworkingonit!TherearesomanybenefitsofusingthePythonprogram.Beginnersaregoingtolovehowreadilyavailablethisprogramisandhoweasyitistolearnsomeofthesimplecommandsinnotime.Eventhosewhohavebeenprogrammingforsometimewillbeimpressedbyhowthisallworks!TheNegativesofWhiletherearealotofreasonstolovePython,itisimportanttorealizethatthereareafewnegativesthatyoushouldwatchoutfor.ThesenegativesItdoesn’thavealotofForthosewhoarelookingtoworkwithaprogramthathasalotofspeed,Pythonmaynotalwaysbethebestoptionforyou.Itisaninterpretedlanguagesothiswillslowitdowncomparedtosomeoftheotheroptionsthatarecompiledlanguages.However,itdoesdependonwhatyouare歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Therearecertainben arkswiththePythoncodethatcanrunfasterusingPyPycomparedtoothercodes.LuckilythisissuewithaslowspeedandPythonisbeingremedied.ProgrammersareworkingtomaketheinterpretingspeedofPythonfastersothatyouwon’thavetocompareitwiththeotherssomuch.Overtime,thehopeisthatPythonwillbeabletoworkatthesamespeedasCandC++orevensomeofthenewerprogramminglanguagesthatarecomingout.NotpresentonmostmobilePythonisagreatoptiontouseifyouhavearegularcomputer.Itisavailableonmanydesktopandserverplatformstohelpyoucreatethecodethatyouarelookingfor.Butitisnotreadytogointomobilecomputing.Sincethereissuchabigincreaseinrevenueandpeoplegoingintothemobileindustry,itissadthatthisprogramminglanguagehasn’tkeptupwiththetrendslikeothers.PerhapsinthefuturePythonwilldecidetogointothefutureanddevelopaversionthatwillbeabletoworkwellwithvariousmobiledevices.Untilthen,programmerswillhavetobesatisfiedwithusingitontheirdesktopand歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍RestrictionswiththeIfyouarelookingtoworkwithaprogramthathasalotofdesignoptions,thePythonprogrammaynotbetherightoptionforyou.Thedesignlanguageisnotuptowhatyouwillfindwithsomeoftheotheroption.Sinceyouareworkingwithaprogramthatisdynamicallytyped,ittakesmoretestingandcanhavemoreerrorsthatwillonlyshowupwhenyouarerunningtheprogram.TheglobalinterpreterlockmeansthatyoucanonlyhaveonethreadaccesstheinternalsofPythonatatime.Thismaynotbeasimportantanymoresinceitiseasytospawnthetasksouttodifferentprocesses,butthedesignisnotasniceassomeoftheotheroptionsthatyouwouldlike.AgoodwaytoworkwiththedesignistorememberthatindentationisimportantwithPython.Otherprogramminglanguagesaregoingtousealotofbracketstoshowthedifferenceinlinesandinformationinsidetheprogram,butPythonisgoingtorelyonindentations.Makesuretobecarefulwithusingthistoavoidissuesanderrorsthatcancomeup.Pythoncanbeoneofthebestprogramsthatyouusetowriteyourown歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍a(chǎn)ndhavesomefun.Whiletherearealotofbenefitstousingthisprogram,especiallycomparedtosomeoftheotheronesthataren’taseasytoread,itisimportanttounderstandboththepositivesandnegativesofeachoptionbeforeyoujumpin!歡迎加入 Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Chapter3:CommonTermsYouShouldKnowwithBeforeyougettoofarintoyourprogrammingwithPython,itisimportanttounderstandsomeofthewordsthatcanmaketheprogrammingeasiertounderstand.ThischapterisgoingtotakesometimetolookatthedifferentwordsthatarecommoninPythonprogramming,andwhichwedotalkaboutabitinthisguidebook,tohelpavoidsomeconfusionandtohelpyougetstartedwithyourfirstcode.Class—thisisatemplatethatwasusedforcreatinguser-definedobjects.Docstring—thisisastringthatwillappearlexicallyfirstexpressioninsideamodule,function,orclassdefinition.Theobjectwillbeavailableto ationtools.Function—thisisablockofcodethatisinvokedwhenusingaprogram.Itisbestusedinordertoprovideacalculationor歡迎加入 Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍a(chǎn)utonomousThisisthebasicinterpreterandeditorenvironmentthatyoucanusealongwithPython.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編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍Chapter4:GettingStartedwithNowthatweknowsomeofthebenefitsofchoosingthisprogram,itistimetogetstartedwithit.Beforeyouareabletolearnsomeofthegreatstepsthatareneededtomakethisprogramcreatecodeforyou,itistimetosetuptheenvironment.ForthosewhohaveacomputerwithMacOSXorUbuntu,youwillalreadyhavePythoninstalledonthesystemThiscanmakethingseasiertogetstartedasyouwilljustneedtoclickontheicontogetstarted.WindowscomputerswillneedtoinstallPython.WhilePythonworksjustfineonWindowscomputers,itdoesn’tcomepreinstalledsoyouwillneedtodothis.ThefollowingstepsworkforWindows7to10:DownloadPython—youcanchoosebetweenPython2orPython3.Botharefantasticoptions;itjustdependsonwhichonewillgetthejobdonefor歡迎加入 Python編程學(xué)習(xí)交 ,群里免費提供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編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍directoriesondifferentNowyoucanopenyourcommandprompt.TodothisclickonStartthenWindowsSystemandthenCommandPrompt.Whenthecommandpromptopens,youcantypein“Python.”ThiswillloadupthePythoninterpreter.YoucanthentypeinExitandhitEntertogetbacktothecommandprompt.YouwillnotbeabletoprogramPythonwithouthavingthetexteditorinplaceonyourcomputer.IfyouareusingWindows,theNotepadfunctionwillwork.MakesurethatyouarenotusingWordthough,itisnotconsideredaneditorandyourcodeisnotgoingtosaveonthesystemproperly.IfyouareconsideringgettingaversionofNotepad,youwillnoticethatNotepad++isthebestonetouseonaWindowscomputerandTextWrangleristhebesttouseforMac.Tosetthemup,dothefollowing:DownloadandtheninstallNotepadOnceitisdownloaded,openupthesettingsandclickon Tab
歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供500+本Python書籍TicktheboxthatisbesideExpandTabsMakesurethatthevalueisat4.ClickagaintoDownloadandtheninstallTextYouwon’tneedtoregistertoinstallthesoftware,justclickCancelifthereisaboxthatcomesupaskingforthis.Otherwise,followtheotherinstructionsthatcomeonthescreentosetthiseditorup.OncetheprogramisonyourcomputeritistimetolearnmoreaboutthecodingandfunctionsthatyoucanenjoyonPython.WhileyouaresettingupPython,makesurethatyoudownloadtheIDLEor歡迎加入非Python編程學(xué)習(xí)交 ,群里免費提供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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 民間貸款合同樣本
- 國際數(shù)據(jù)中心檢查井施工協(xié)議
- 寫字樓租賃續(xù)約合同
- 大學(xué)教職工宿舍租賃協(xié)議
- 校園綠化養(yǎng)護工程合同
- 汽車維修車間建設(shè)合同
- 天然氣調(diào)壓站建設(shè)協(xié)議
- 農(nóng)田灌溉項目施工合同模板
- 制造業(yè)加工合同簽訂指南
- 教育機構(gòu)文秘招聘合同書
- 《小米手機營銷策略研究開題報告(含提綱)》
- 工程教育認(rèn)證學(xué)校培訓(xùn)試題含答案
- 學(xué)校校長通訊錄
- 外挑水平防護網(wǎng)方案
- 高中英語 必修一知識點(北師大版)課件
- 溝通技巧(直接可以授課用)
- 證據(jù)材料目錄證據(jù)清單范本
- (新版)供電可靠性(初級)理論普考題庫及答案匯總-下(判斷題)
- 各類茶的沖泡方法課件
- 高血壓病例分析培訓(xùn)課件
- 粉煤灰燒失量、細(xì)度、比表面積試驗檢測記錄表
評論
0/150
提交評論