Learn to Program with Python

woride7792 51 0 PDF 2019-09-20 11:09:59

Learn to Program with Python by Irv KalbEnglish | 7 Sept. 2016 | ISBN: 148421868X | 288 Pages | PDF (True) | 7.33 MBGet started in the world of software development: go from zero knowledge of programming to comfortably writing small to medium-sized programs in Python. Programming can be intimidatLearn to Program with Pythonry kaMountain view California, USAISBN-13(pbk):978-14842-1868-6ISBN-13( electronic):978-1-4842-2172-3DOI10.1007/978-1-4842-2172-3Library of congress Control Number: 2016949498Copyright o 2016 by Irv KalbThis work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of thematerial is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storageand retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known orhereafter developedTrademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with everyoccurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashionand to the benefit of the trademark owner with no intention of infringement of the trademarkThe use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identifiedas such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rightsWhile the advice and information in this book are believed to be true and accurate at the date of publication, neitherthe authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that maybe made. The publisher makes no warranty, express or implied, with respect to the material contained hereinManaging Director: Welmoed SpahrLead Editor: Steve AnglinTechnical reviewer: Michael thomasEditorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan, JonathanGennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, James Markham, Susan McDermottMatthew Moodie, Natalie Pao, Gwenan SpearingCoordinating Editor: Mark PowersCopy editor: Kim Burton-WeismanCompositor: SPi GlobalIndexer: SPi GlobalArtist: SPi globalDistributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-nyospringer-sbm. com,orvisitwww.springeronline.com.apressMedia,LlcisaCaliforniaLlcandthesolemember(owner)isSpringerScience Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporationForinformationontranslationspleasee-mailrights@apress.com,orvisitwww.apress.comApress and friends of ed books may be purchased in bulk for academic, corporate, or promotional use eBookversions and licenses are also available for most titles. For more information, reference our Special Bulk Sales-eBookLicensingwebpageatwww.apress.com/bulk-salesAny source code or other supplementary materials referenced by the author in this text are available to readers atwww.apress.com/9781484218686.Fordetailedinformationabouthowtolocateyourbookssourcecodegotowww.apress.com/source-code.ReaderscanalsoaccesssourcecodeatSpringerlinkintheSupplementaryMMaterial section for each chapter.Printed on acid-free paperThis book is dedicated to the memory of my mother, Lorraine kalbI started learning about programming when I was 16 years old, at ColumbiaHigh School in maplewood, N. We were extremely fortunate to have a veryearly computer, an IBM 1130, that students could useI remember learning the basics of the fortran programming language andwriting a simple program that would add two numbers together and print theresult. I was thrilled when I finally got my program to work correctly. It was arewarding feeling to be able to get this huge, complicated machine to doexactly what i wanted it to doI clearly remember explaining to my mother that I wrote this program thatgot the computer to add 9 and 5 and come up with an answer of 14. She saidthat she didn't need a computer to do that. I tried to explain to her that gettingthe answer of 14 was not the important part. What was important was that i hadwritten a program that would add any two numbers and print the resultShe still didn't get it, but she was happy for me and very supportiveHopefully, through my explanations in this book, you will get itContents at a glanceAbout the author■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■国■■国■■a■■■■■About the technical reviewerAcknowledgmentsChapter 1: Getting Started aRhat■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Chapter 2: variables and assignment Statements maat■■■■■■■■■■■口■■■■■■■■■■■■■■■■a■a■国■■■7Chapter 3: Built-in Functions.mman35Chapter 4: User-Defined Functions. aa47Chapter 5: if, else, and elif Statements nmma: 71Chapter6:L00ps,,,,,,,,,m,,,,,算103Chapter 7: Listsu133Chapter 8: Strings.■■■■■■■■■■■■■■■■■■國■■■■■■■■■■■國■■■■■■■■■■■■■■■■■■■■■■■國■■■■■■■■■■■圆■■国■■a■■■■■■■a■口■■圆a■165Chapter9: File Input/Output,,,,,…,,,,…,…,,,,,,…181Chapter 10: Internet Data aeaeasammeaaana209Chapter 11: Data Structures .ammmmBRRRRRBRRRRBRRI aR 227Chapter 12: Where to Go from Here mmmm mmmm 257Index 261ContentsAbout the authorAbout the technical reviewerAcknowledgmentsXXChapter 1: Getting Started aRhatWelcomeWhat Is python?…Installing PythonIDLE and the python ShellHello worldCreating, Saving, and running a Python FileIDLE on Multiple Platforms223466SummaryChapter 2: variables and assignment Statements aA Sample Python ProgramThe Building blocks of Programming .Four Types of Data......,,………,10Floats日日日日日日日自日日a日自日日自日日自日日自日日自日日自日日自日日自日日自日日日日自日日自日自日日面日日面日目面日目面日面面日面日面日面B面10stringBooleanmples of DataForm with Underlying Data日日日日日日日日日日自日日自日日自日日自日日自日日自日日自日日自日日日日日日日日日日日面12CONTENTSVariables13Assignment Statements16Variable names18Naming convention19Keywords20Case sensitivity21More Complicated Assignment Statements................21Print statements∴22Simple Math24Order of operations26First Python Programs27Shorthand Naming convention28Adding comments30F叫l|- Line comment30Add a comment after a line of code30Multiline comment…30Whitespace31Error32Syntax Error32Exception Error….3Logic Er34Summary.34Chapter 3: Built-in Functions.■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■国■■■35Overview of built-in FunctionsFunction call36Arguments36Results36Built-in type Function....meseeemneon36V11INTENTSGetting Input from the User38Conversion functions39int Functionfloat functionstr function,……First Real ProgramsConcatenation42Another Programming Exercise3Using Function Calls Inside Assignment Statements45Summary46Chapter 4: User-Defined Functions aaa IaEIRERRIIa: 47A Recipe as an Analogy for Building Software48Ingredients....48Directions…48Definition of a Function50Building Our First Function.......……………51Calling a User-Defined Function51Receiving Data in a User-Defined Function: Parameters53Building user-Defined Functions with Parameters.Building a simple Function that Does Addition…56Building a Function to calculate an Average.57Returning a value from a Function The return statement57Returning No value: None59Returning More Than One value59Specific and General Variable Names in Calls and Functions .Temperature Conversion Functions61Placement of Functions in a Python File62Never Write Multiple Copies of the Same Code62Constants64IX

用户评论
请输入评论内容
评分:
暂无评论