




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
PythonPythonProgrammingforByAdamCopyright?2016byAdamAllrights.Nopartofthispublicationmaybereproduced,distributed,ortransmittedinanyformorbyanymeans,includingphotocopying,recording,orotherelectronicormechanicalmethods,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembodiedincriticalreviewsandcertainother mercialusespermittedbycopyrightlaw.TableofChapter1:LearningAboutPythonTheOriginsofPythonWhyUseChapter2:TheBenefitsandNegativesofPythonTheBenefitsofPythonTheNegativesofChapter3:CommonTermsYouShouldKnowwithPythonChapter4:GettingStartedwithPythonTextEditorChapter5:LearningtheBasicsofPythonProgrammingChapter6:ABitMoreonCommentsChapter7:VariablesandWhatTheyDoinPython歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Gettingstartedincodingcanbetough.Youmayhavelookedatafewofthemostpopularcodinglanguages,suchasC++orJavaandbeenabitscaredbywhatyousaw.Thepagesmayhavebeenfilledtothebrimwithlettersandsymbolsthatyoujustdidn’tunderstand,andyoubecamefrustratedandjustwantedtowalkaway.Manypeoplearescaredofprogramingandfeellikeitisjusttoohardforthem.ButwiththePythonprogramminglanguage,youwillfindthatitcanbeeasierthanevertolearnaboutcodingandtoevenreaditlikeaprofessional.ThisguidebookisgoingtogiveyousomeofthebasicsthatyouneedtogetstartedwithPythonprogramming.WewillstartoutabittalkingaboutwhatPythonprogrammingisaswellassomeofthestepsthatyoushouldtakeinordertodownloadtheprogram,ifitisn’talreadypresentonyourcomputer,andgiveyousomemoreinformationtoreallyunderstandwhythisprogramissogreat.Wewillthenmoveontosome thatwillbeusefultoyouwhenstartingoutwiththeprogramandeventalkaboutthebenefitsandthedrawbacksofusingPythonforallyourcodingandprogramingneeds.Therestoftheguidebookisdevotedtotalkingaboutsomeofthe歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍thingsthatyoucandowithinthePythonprogramaswellassomeexamplesofhoweachofthesewouldwork.Wetalkaboutaddingcommentsintothecode,workingwithstringsandintegers,andevenspendsometimeworkingwithvariablessothattheywillshowuprightintheprogram.Itisagreatideatoexperimentabitwiththeprocess.PythonmakesiteasytotestoutyourstringssothatyoucanfigureoutwhatisgoingtoworkandwhatneedssomemoreGettingstartedinprogramingcanseemlikeachallenge.Youmayworrythatyouaren’tgoingtobeabletofigureitalloutandallofthosecrazyprograminglanguagesmayhavescaredyouawayinthefirstplace.ThisguidebookisgoingtospendsometimelookingatthePythonlanguageandexploringhoweasyitcanbetogetstartedwiththissimpleprogram.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Chapter1:LearningAboutThecomputerworldhasbroughtinmanydifferenttypesofpeople.Someareinterestedinmakingmoneycreatingtheirownprogramstoselltoothers.Somejustliketomessaroundandlearndifferentthingsabouthowthecomputerwillwork.Andstillothershavedevotedtheirlivestoprogramming,makingittheproductthatbringshometheir eeachmonthwhethertheyworkatrepairingcomputers,workinacorporationtokeepthecomputerssafe,or someotheraspectofcomputertechnology.Whenitcomestocomputertechnology,nothingisgoingtobesimple.Beforeyoucanevengetaprogramtoworkonthecomputer,itneedstoreceivetherightcodetomakeitwork.ThereareseveraloptionsforcodecreationthatcomputertechcanchooseincludingJava,C++andPython.Herewe歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍exploreabitaboutPythonandwhyitisoftenpreferredovertheothertwoprogrammingoptions.BeforeyouareabletostartusingPythontotakeoveryourprogrammingneeds,itisimportanttostartlearningmoreaboutitandallofthegreatbenefitsyouwillreceivewhenusingthisprogram.Pythonisahighlevelprogrammingtool,whichmeansthatitiseasytouseandread,evenasabeginner.Thephilosophybehindthecodeisreadabilityandithasatypeofsyntaxthatallowstheprogrammertoexpresstheirconceptswithouthavingpagesofcodealongwithit.Comparedtousingotherpopularcodes,likeJavaandC++,thiscanmakePythonmucheasiertocomplete.Thephilosophyofthiscodelanguageissimpleenoughtouse.Itbelievesthatasimpledesignissomuchbetterthanacomplexoneandthatreadabilityisimportant.Thisisagreatlanguageforbeginnerstogetstartedonbecausetheywillactuallybeabletoreadandunderstandthecodetheyareputtingin.Withotheroptions,theymayhavetospendalotoftimetryingtogetthecodejustright,addinginmanyothersymbolstogetittowork.ButwithPython,itiskeptmuchsimplerandyoumayfindthatitiseasiertoreadthroughthelinesandseewhatyouare SomeofthefeaturesthatyoumaylikewithPython歡迎加入 Python編程學(xué)習(xí)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供500+本Python書籍uploading.Despitethis,mosthavestuckwithPython2.0forWhyUseAsyoucanprobablyguess,thereareseveraldifferentcomputercodingprogramsthatyoucanchoosetouse.Butwhiletherearesomebenefitstousingtheseotherprograms,Pythonisoneofthebestoptionsoutthere.Itiseasytouse,hasalotofoptionsforyoutochoosefrom,anditcanevenbeusedoveravarietyofplatformswithouthavingtochangethingsup.SomeofthebenefitsthatyouwilllovewithPythoninclude:PythonisdesignedtoworkwiththeEnglishlanguage,makingiteasytoread.Therearealsostrictrulesintermsofpunctuationontheprogramsoyouaren’tjustlookingatbracketsallovertheplace.Pythonalsomakessurethattheprogrammerknowshowtoformateverythingthankstoasetofrulesthatareinplace,makingiteasyforeveryonetocreateacodethatotherscanfollow.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Pythonhasbeenaroundforover25yearsnowandsinceitisoneoftheeasiestcodestolearnhowtouse,therehavebeenquiteafewdifferentcodeswrittenusingthesystem.Thegoodnewsisthatthissystemisopensourcedsothatthecodeisavailableforanyprogrammertouse.YoucaninstallthePythonprograminyourownsystemanduseitforyourown aluse.Whetheryouareusingthecodestofinishoffaproductortowritesomeofyourowncodes,thelibraryofPythoniseasytouse.Thecodesthatyouwantwillbeinstalledintothelibrariesandsincetheprogramhasbeenaroundforalongtie,theyaregoingtocoverprettymuchwhateveryouwantfromautomatingyourservertomakingchangestoapicture.SincePythonissopopular,thecommunityforPythonisprettybig.Thereareconferenceswithlotsofnetworkingandworkshopsavailableforthisprogrammingproductsandlotsofplacesyoucanvisit,bothonlineandoffline,toaskquestionsortolearnmoreabouttheprogram.YoumaywanttoconsidercheckingoutafewoftheseplacesifyouareabeginnerwithPythonasitcanhelpyoutolearnmoreandeventomeetsomenewpeople.Ifyouareinterestedingettingstartedwithcoding,Pythonisoneoftheoptionsthatyoucanmake.Itissimpletogetstartedonandsinceitwill歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍onavarietyofdifferentplatforms,itissuretoworkonyour computer.Sinceitiseasytoread,youwillfindthatcodingdoesn’thavetobeachallengeandyoucancreateyourown,orlearnfromothersinnotime.歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Chapter2:TheBenefitsandNegativesofPythonisagreatprogramtousewhetheryouareabeginnerintheprogrammingworldoryouhavebeenintoitforsometime.ManyofthosewhoarejustlookingatgettingstartedwithprogrammingwilljumprightinwithPythonandmakeittheirown.Itissimpletounderstandandcanbeusedbyanyonewhoisreadytogetstartedwithcoding.Thischapterisgoingtotakesometimetoexplainsomeofthepositives,aswellassomeofthedrawbacks,ofusingPythonforyourprogramminglanguage.TheBenefitsofPythonisprobablyoneofthebestprogramminglanguagesthatyoucantouse.Beginnersaregoingtolovehoweasyitistoturnonthisprogram歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供500+本Python書籍makethingseasier.Itwillbeabletotakethewordsthatyouaretyandspitthembackout,withthehelpoftheinterpreter,injustafewseconds.Youcantestwhatyouare ngwhileyouareworkingonit!TherearesomanybenefitsofusingthePythonprogram.Beginnersaregoingtolovehowreadilyavailablethisprogramisandhoweasyitistolearnsomeofthesimplecommandsinnotime.Eventhosewhohavebeenprogrammingforsometimewillbeimpressedbyhowthisallworks!TheNegativesofWhiletherearealotofreasonstolovePython,itisimportanttorealizethatthereareafewnegativesthatyoushouldwatchoutfor.ThesenegativesItdoesn’thavealotofForthosewhoarelookingtoworkwithaprogramthathasalotofspeed,Pythonmaynotalwaysbethebestoptionforyou.Itisaninterpretedlanguagesothiswillslowitdowncomparedtosomeoftheotheroptionsthatarecompiledlanguages.However,itdoesdependonwhatyouare歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Therearecertainben arkswiththePythoncodethatcanrunfasterusingPyPycomparedtoothercodes.LuckilythisissuewithaslowspeedandPythonisbeingremedied.ProgrammersareworkingtomaketheinterpretingspeedofPythonfastersothatyouwon’thavetocompareitwiththeotherssomuch.Overtime,thehopeisthatPythonwillbeabletoworkatthesamespeedasCandC++orevensomeofthenewerprogramminglanguagesthatarecomingout.NotpresentonmostmobilePythonisagreatoptiontouseifyouhavearegularcomputer.Itisavailableonmanydesktopandserverplatformstohelpyoucreatethecodethatyouarelookingfor.Butitisnotreadytogointomobilecomputing.Sincethereissuchabigincreaseinrevenueandpeoplegoingintothemobileindustry,itissadthatthisprogramminglanguagehasn’tkeptupwiththetrendslikeothers.PerhapsinthefuturePythonwilldecidetogointothefutureanddevelopaversionthatwillbeabletoworkwellwithvariousmobiledevices.Untilthen,programmerswillhavetobesatisfiedwithusingitontheirdesktopand歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍RestrictionswiththeIfyouarelookingtoworkwithaprogramthathasalotofdesignoptions,thePythonprogrammaynotbetherightoptionforyou.Thedesignlanguageisnotuptowhatyouwillfindwithsomeoftheotheroption.Sinceyouareworkingwithaprogramthatisdynamicallytyped,ittakesmoretestingandcanhavemoreerrorsthatwillonlyshowupwhenyouarerunningtheprogram.TheglobalinterpreterlockmeansthatyoucanonlyhaveonethreadaccesstheinternalsofPythonatatime.Thismaynotbeasimportantanymoresinceitiseasytospawnthetasksouttodifferentprocesses,butthedesignisnotasniceassomeoftheotheroptionsthatyouwouldlike.AgoodwaytoworkwiththedesignistorememberthatindentationisimportantwithPython.Otherprogramminglanguagesaregoingtousealotofbracketstoshowthedifferenceinlinesandinformationinsidetheprogram,butPythonisgoingtorelyonindentations.Makesuretobecarefulwithusingthistoavoidissuesanderrorsthatcancomeup.Pythoncanbeoneofthebestprogramsthatyouusetowriteyourown歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍a(chǎn)ndhavesomefun.Whiletherearealotofbenefitstousingthisprogram,especiallycomparedtosomeoftheotheronesthataren’taseasytoread,itisimportanttounderstandboththepositivesandnegativesofeachoptionbeforeyoujumpin!歡迎加入 Python編程學(xué)習(xí)交 ,群里免費(fèi)提供500+本Python書籍Chapter3:CommonTermsYouShouldKnowwithBeforeyougettoofarintoyourprogrammingwithPython,itisimportanttounderstandsomeofthewordsthatcanmaketheprogrammingeasiertounderstand.ThischapterisgoingtotakesometimetolookatthedifferentwordsthatarecommoninPythonprogramming,andwhichwedotalkaboutabitinthisguidebook,tohelpavoidsomeconfusionandtohelpyougetstartedwithyourfirstcode.Class—thisisatemplatethatwasusedforcreatinguser-definedobjects.Docstring—thisisastringthatwillappearlexicallyfirstexpressioninsideamodule,function,orclassdefinition.Theobjectwillbeavailableto ationtools.Function—thisisablockofcodethatisinvokedwhenusingaprogram.Itisbestusedinordertoprovideacalculationor歡迎加入 Python編程學(xué)習(xí)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供500+本Python書籍Chapter4:GettingStartedwithNowthatweknowsomeofthebenefitsofchoosingthisprogram,itistimetogetstartedwithit.Beforeyouareabletolearnsomeofthegreatstepsthatareneededtomakethisprogramcreatecodeforyou,itistimetosetuptheenvironment.ForthosewhohaveacomputerwithMacOSXorUbuntu,youwillalreadyhavePythoninstalledonthesystemThiscanmakethingseasiertogetstartedasyouwilljustneedtoclickontheicontogetstarted.WindowscomputerswillneedtoinstallPython.WhilePythonworksjustfineonWindowscomputers,itdoesn’tcomepreinstalledsoyouwillneedtodothis.ThefollowingstepsworkforWindows7to10:DownloadPython—youcanchoosebetweenPython2orPython3.Botharefantasticoptions;itjustdependsonwhichonewillgetthejobdonefor歡迎加入 Python編程學(xué)習(xí)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供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í)交 ,群里免費(fèi)提供500+本Python書籍TicktheboxthatisbesideExpandTabsMakesurethatthevalueisat4.ClickagaintoDownloadandtheninstallTextYouwon’tneedtoregistertoinstallthesoftware,justclickCancelifthereisaboxthatcomesupaskingforthis.Otherwise,followtheotherinstructionsthatcomeonthescreentosetthiseditorup.OncetheprogramisonyourcomputeritistimetolearnmoreaboutthecodingandfunctionsthatyoucanenjoyonPython.WhileyouaresettingupPython,makesurethatyoudownloadtheIDLEor歡迎加入非Python編程學(xué)習(xí)交 ,群里免費(fèi)提供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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 行政管理考試附加學(xué)習(xí)試題及答案提示
- 行政管理中新媒體的應(yīng)用與影響分析試題及答案
- 四川省涼山彝族自治州寧南縣2023-2024學(xué)年英語(yǔ)三年級(jí)下學(xué)期英語(yǔ)期中模擬試卷(含答案)
- 深度分析藥理學(xué)考試試題及答案
- 2024年計(jì)算機(jī)基礎(chǔ)考試總結(jié)思路試題及答案
- 國(guó)軍標(biāo)內(nèi)審員試題及答案
- 2024年計(jì)算機(jī)基礎(chǔ)考試內(nèi)容概述及試題和答案
- 2024食品質(zhì)檢員基礎(chǔ)教材與試題答案
- 美容師考試個(gè)人品牌建設(shè)與試題答案
- 藥理學(xué)考試沖刺的試題及答案練習(xí)
- 2025年山東省青島市高考地理一模試卷
- 醫(yī)院培訓(xùn)課件:《醫(yī)療安全(不良)事件報(bào)告制度》
- 物理-重慶市南開(kāi)中學(xué)高2025屆高三第七次質(zhì)量檢測(cè)暨3月月考試題和答案
- 2025屆高考地理二輪復(fù)習(xí)高考非選擇題專練專練八以世界典型區(qū)域?yàn)楸尘暗木C合題含解析
- 2025年單位節(jié)日集體福利慰問(wèn)品采購(gòu)合同8篇
- 大學(xué)生網(wǎng)絡(luò)安全與道德規(guī)范管理指南
- 2025屆泉州市高三語(yǔ)文三檢作文題目解析及相關(guān)范文:光靠理性還不足以解決我們社會(huì)生活的問(wèn)題
- 第16課《大家排好隊(duì)》名師課件
- 湖北咸寧咸安區(qū)招引碩士、博士研究生人才41人高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 2024江西撫州市市屬國(guó)有企業(yè)招聘員工入闈人員筆試參考題庫(kù)附帶答案詳解
- T-CWEC 37-2023 著生藻類監(jiān)測(cè)技術(shù)規(guī)范
評(píng)論
0/150
提交評(píng)論