Learn to Program with Python (eBook)

(Autor)

eBook Download: PDF
2016 | 1st ed.
XXI, 263 Seiten
Apress (Verlag)
978-1-4842-2172-3 (ISBN)

Lese- und Medienproben

Learn to Program with Python - Irv Kalb
Systemvoraussetzungen
39,58 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

Get 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 intimidating (especially when most books on software require you to know and use obscure command line instructions) but it doesn't have to be that way!

In Learn to Program with Python, author Irv Kalb uses his in-person teaching experience to guide you through learning the Python computer programming language. He uses a conversational style to make you feel as though he is your personal tutor. All material is laid out in a thoughtful manner, each lesson building on previous ones. Many real-world analogies make the material easy to relate to. A wide variety of well-documented examples are provided.  Along the way, you'll develop small programs on your own through a series of coding challenges that reinforce the content of the chapters.


What You Will Learn:  
  • Learn fundamental programming concepts including: variables and assignment statements, functions, conditionals, loops, lists, strings, file input and output, Internet data, and data structures
  • Get comfortable with the free IDLE Interactive Development Environment (IDE), which you will use to write and debug all your Python code - no need to use the command line!
  • Build text-based programs, including a number of simple games
  • Learn how to re-use code by building your own modules
  • Use Python's built-in data structures and packages to represent and make use of complex data from the Internet

Who this book is for:
This book assumes that you have absolutely no prior knowledge about programming. There is no need to learn or use any obscure Unix commands. Students of any age who have had no exposure to programming and are interested in learning to do software development in the Python language. The book can be used as a text book associated with a high school or college introduction to computer science course.  Secondly, people who have had exposure to some computer language other than Python, who would like to build good habits for programming in Python.


Irv Kalb has a BS and MS in Computer Science.  He has worked as a software developer, manager of software developers, manager of software development projects, and as a teacher of software for entire career.  He has worked both as an employee for a number of technical companies and for many years as an independent consultant.  He has been developing been writing technical articles and ebooks about software since 2000, and has been teaching software development in Silicon Valley colleges since 2010.
Get 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 intimidating (especially when most books on software require you to know and use obscure command line instructions) but it doesn't have to be that way!In Learn to Program with Python, author Irv Kalb uses his in-person teaching experience to guide you through learning the Python computer programming language. He uses a conversational style to make you feel as though he is your personal tutor. All material is laid out in a thoughtful manner, each lesson building on previous ones. Many real-world analogies make the material easy to relate to. A wide variety of well-documented examples are provided.  Along the way, you'll develop small programs on your own through a series of coding challenges that reinforce the content of the chapters.What You Will Learn  Learn fundamental programming concepts including: variables and assignment statements, functions, conditionals, loops, lists, strings, file input and output, Internet data, and data structuresGet comfortable with the free IDLE Interactive Development Environment (IDE), which you will use to write and debug all your Python code - no need to use the command line!Build text-based programs, including a number of simple gamesLearn how to re-use code by building your own modulesUse Python's built-in data structures and packages to represent and make use of complex data from the InternetWho This Book Is ForThis book assumes that you have absolutely no prior knowledge about programming. There is no need to learn or use any obscure Unix commands. Students of any age who have had no exposure to programming and are interested in learning to do software development in the Python language. The book can be used as a text book associated with a high school or college introduction to computer science course.  Secondly, people who have had exposure to some computer language other than Python, who would like to build good habits for programming in Python.

Irv Kalb has a BS and MS in Computer Science.  He has worked as a software developer, manager of software developers, manager of software development projects, and as a teacher of software for entire career.  He has worked both as an employee for a number of technical companies and for many years as an independent consultant.  He has been developing been writing technical articles and ebooks about software since 2000, and has been teaching software development in Silicon Valley colleges since 2010.

Contents at a Glance 6
Contents 8
About the Author 18
About the Technical Reviewer 20
Acknowledgments 22
Chapter 1: Getting Started 23
Welcome 23
What Is Python? 23
Installing Python 24
IDLE and the Python Shell 24
Hello World 25
Creating, Saving, and Running a Python File 26
IDLE on Multiple Platforms 28
Summary 28
Chapter 2: Variables and Assignment Statements 29
A Sample Python Program 30
The Building Blocks of Programming 31
Four Types of Data 32
Integers 32
Floats 32
Strings 32
Booleans 33
Examples of Data 33
Form with Underlying Data 34
Variables 35
Assignment Statements 38
Variable Names 40
Naming Convention 41
Keywords 42
Case Sensitivity 43
More Complicated Assignment Statements 43
Print Statements 44
Simple Math 46
Order of Operations 48
First Python Programs 49
Shorthand Naming Convention 50
Adding Comments 52
Full-Line Comment 52
Add a Comment After a Line of Code 52
Multiline Comment 52
Whitespace 53
Errors 54
Syntax Error 54
Exception Error 55
Logic Error 56
Summary 56
Chapter 3: Built-in Functions 57
Overview of Built-in Functions 57
Function Call 58
Arguments 58
Results 58
Built-in type Function 58
Getting Input from the User 60
Conversion Functions 61
int Function 61
float Function 61
str Function 61
First Real Programs 62
Concatenation 64
Another Programming Exercise 65
Using Function Calls Inside Assignment Statements 67
Summary 68
Chapter 4: User-Defined Functions 69
A Recipe as an Analogy for Building Software 70
Ingredients 70
Directions 70
Definition of a Function 72
Building Our First Function 73
Calling a User-Defined Function 73
Receiving Data in a User-Defined Function: Parameters 75
Building User-Defined Functions with Parameters 76
Building a Simple Function that Does Addition 78
Building a Function to Calculate an Average 79
Returning a Value from a Function: The return Statement 79
Returning No Value: None 81
Returning More Than One Value 81
Specific and General Variable Names in Calls and Functions 82
Temperature Conversion Functions 83
Placement of Functions in a Python File 84
Never Write Multiple Copies of the Same Code 84
Constants 86
Scope 86
Global Variables and Local Variables with the Same Names 89
Finding Errors in Functions: Traceback 90
Summary 92
Chapter 5: if, else, and elif Statements 93
Flowcharting 94
The if Statement 96
Comparison Operators 98
Examples of if Statements 98
Nested if Statement 99
The else Statement 100
Using if/else Inside a Function 102
The elif Statement 102
Using Many elif Statements 104
A Grading Program 106
A Small Sample Program: Absolute Value 106
Programming Challenges 108
Negative, Positive, Zero 108
isSquare 110
isEven 113
isRectangle 115
Conditional Logic 116
The Logical not Operator 117
The Logical and Operator 117
The Logical or Operator 118
Precedence of Comparison and Logical Operators 119
Booleans in if Statements 120
Program to Calculate Shipping 120
Summary 123
Chapter 6: Loops 124
User’s View of the Game 125
Loops 126
The while Statement 127
First Loop in a Real Program 129
Increment and Decrement 130
Running a Program Multiple Times 131
Python Built-in Packages 132
Generating a Random Number 133
Simulation of Flipping a Coin 134
Other Examples of Using Random Numbers 135
Creating an Infinite Loop 136
A New Style of Building a Loop: while True, and break 137
The continue Statement 139
Asking If the User Wants to Repeat: the Empty String 141
Pseudocode 141
Building the “Guess the Number” Program 142
Playing a Game Multiple Times 146
Error Checking with try/except 148
Building Error-Checking Utility Functions 150
Coding Challenge 151
Summary 153
Chapter 7: Lists 154
Collections of Data 155
Lists 155
Elements 156
Python Syntax for a List 156
Empty List 157
Position of an Element in a List: Index 157
Accessing an Element in a List 158
Using a Variable or Expression as an Index in a List 159
Changing a Value in a List 161
Using Negative Indices 161
Building a Simple Mad Libs Game 162
Adding a List to Our Mad Libs Game 163
Determining the Number of Elements in a List: The len Function 164
Programming Challenge 1 165
Using a List Argument with a Function 167
Accessing All Elements of a List: Iteration 168
for Statements and for Loops 169
Programming Challenge 2 171
Generating a Range of Numbers 172
Programming Challenge 3 173
Scientific Simulations 175
List Manipulation 178
List Manipulation Example: An Inventory Example 179
Pizza Toppings Example 180
Summary 184
Chapter 8: Strings 185
len Function Applied to Strings 186
Indexing Characters in a String 186
Accessing Characters in a String 187
Iterating Through Characters in a String 188
Creating a Substring: A Slice 190
Programming Challenge 1: Creating a Slice 191
Additional Slicing Syntax 193
Slicing As Applied to a List 194
Strings Are Not Changeable 194
Programming Challenge 2: Searching a String 195
Built-in String Operations 196
Examples of String Operations 198
Programming Challenge 3: Directory Style 198
Summary 200
Chapter 9: File Input/Output 201
Saving Files on a Computer 202
Defining a Path to a File 202
Reading from and Writing to a File 204
File Handle 205
The Python os Package 206
Building Reusable File I/O Functions 206
Example Using Our File I/O Functions 207
Importing Our Own Modules 208
Saving Data to a File and Reading It Back 210
Building an Adding Game 212
Programming Challenge 1 212
Programming Challenge 2 213
Writing/Reading One Piece of Data to and from a File 216
Writing/Reading Multiple Pieces of Data to and from a File 217
The join Function 217
The split Function 218
Final Version of the Adding Game 219
Writing and Reading a Line at a Time with a File 221
Example: Multiple Choice Test 223
A Compiled Version of a Module 228
Summary 228
Chapter 10: Internet Data 229
Request/Response Model 229
Request with Values 231
Example URL: Getting a Stock Price 231
Pretending to Be a Browser 232
API 233
Example Program to Get Stock Price Information Using an API 234
Example Program to Get Exchange Rate Information 236
Example Program to Get Powerball Information 239
API Key 243
URL Encoding 243
Summary 245
Chapter 11: Data Structures 246
Tuple 247
Lists of Lists 249
Representing a Grid or a Spreadsheet 250
Representing the World of an Adventure Game 250
Reading a Comma-Separated Value (.csv) File 253
Dictionary 257
Using the in Operator on a Dictionary 259
Programming Challenge 260
A Python Dictionary to Represent a Programming Dictionary 261
Iterating Through a Dictionary 262
Combining Lists and Dictionaries 263
JSON: JavaScript Object Notation 265
Example Program to Get Weather Data 267
XML Data 269
Accessing Repeating Groupings in JSON and XML 272
Summary 274
Chapter 12: Where to Go from Here 275
Python Language Documentation 275
Python Standard Library 275
Python External Packages 276
Python Development Environments 277
Places to Find Answers to Questions 277
Projects and Practice, Practice, Practice 278
Summary 278
Index 279

Erscheint lt. Verlag 22.8.2016
Zusatzinfo XXI, 263 p. 36 illus., 3 illus. in color.
Verlagsort Berkeley
Sprache englisch
Themenwelt Informatik Programmiersprachen / -werkzeuge Python
Mathematik / Informatik Informatik Web / Internet
Schlagworte Computer Science • Development • Engineering • Examples • Game • object oriented • programming • Python • Software
ISBN-10 1-4842-2172-9 / 1484221729
ISBN-13 978-1-4842-2172-3 / 9781484221723
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 7,6 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
ein kompakter Einstieg für die Praxis

von Ralph Steyer

eBook Download (2024)
Springer Vieweg (Verlag)
34,99
Arbeiten mit NumPy, Matplotlib und Pandas

von Bernd Klein

eBook Download (2023)
Carl Hanser Verlag GmbH & Co. KG
29,99