23,99 €
Learn Python--the fun and easy way--and get in theprogramming game today! Python is one of the fastest growing programming languages, andno wonder. It requires three to five times less time thandeveloping in Java, is a great building block for learning bothprocedural and object-oriented programming concepts, and is anideal language for data analysis. Beginning Programming withPython For Dummies is the perfect guide to this dynamic andpowerful programming language--even if you've never codedbefore! Author John Paul Mueller draws on his vast programmingknowledge and experience to guide you step-by-step through thesyntax and logic of programming with Python and provides severalreal-world programming examples to give you hands-on experiencetrying out what you've learned. * Provides a solid understanding of basic computer programmingconcepts and helps familiarize you with syntax and logic * Explains the fundamentals of procedural and object-orientedprogramming * Shows how Python is being used for data analysis and otherapplications * Includes short, practical programming samples to apply yourskills to real-world programming scenarios Whether you've never written a line of code or are just tryingto pick up Python, there's nothing to fear with the fun andfriendly Beginning Programming with Python For Dummiesleading the way.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 494
Veröffentlichungsjahr: 2014
Beginning Programming with Python® For Dummies®
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2014 by John Wiley & Sons, Inc., Hoboken, New Jersey
Media and software compilation copyright © 2014 by John Wiley & Sons, Inc. All rights reserved.
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Python is a registered trademark of Python Software Foundation Corporation. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2014935516
ISBN 978-1-118-89145-2 (pbk); ISBN 978-1-118-89147-6 (ebk); ISBN ePDF 978-1-118-89149-0 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Table of Contents
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Part I: Getting Started with Python
Chapter 1: Talking to Your Computer
Understanding Why You Want to Talk to Your Computer
Knowing that an Application is a Form of Communication
Thinking about procedures you use daily
Writing procedures down
Seeing applications as being like any other procedure
Understanding that computers take things literally
Defining What an Application Is
Understanding that computers use a special language
Helping humans speak to the computer
Understanding Why Python is So Cool
Unearthing the reasons for using Python
Deciding how you can personally benefit from Python
Discovering which organizations use Python
Finding useful Python applications
Comparing Python to other languages
Chapter 2: Getting Your Own Copy of Python
Downloading the Version You Need
Installing Python
Working with Windows
Working with the Mac
Working with Linux
Accessing Python on Your Machine
Using Windows
Using the Mac
Using Linux
Testing Your Installation
Chapter 3: Interacting with Python
Opening the Command Line
Starting Python
Using the command line to your advantage
Using Python environment variables to your advantage
Typing a Command
Telling the computer what to do
Telling the computer you’re done
Seeing the result
Using Help
Getting into help mode
Asking for help
Leaving help mode
Obtaining help directly
Closing the Command Line
Chapter 4: Writing Your First Application
Understanding the Integrated DeveLopment Environment (IDLE)
Starting IDLE
Using standard commands
Understanding color coding
Getting GUI help
Configuring IDLE
Creating the Application
Opening a new window
Typing the command
Saving the file
Running the Application
Understanding the Use of Indentation
Adding Comments
Understanding comments
Using comments to leave yourself reminders
Using comments to keep code from executing
Loading and Running Existing Applications
Using the command line or terminal window
Using the Edit window
Using the Python Shell window or Python command line
Closing IDLE
Part II: Talking the Talk
Chapter 5: Storing and Modifying Information
Storing Information
Seeing variables as storage boxes
Using the right box to store the data
Defining the Essential Python Data Types
Putting information into variables
Understanding the numeric types
Understanding Boolean values
Understanding strings
Working with Dates and Times
Chapter 6: Managing Information
Controlling How Python Views Data
Making comparisons
Understanding how computers make comparisons
Working with Operators
Defining the operators
Understanding operator precedence
Creating and Using Functions
Viewing functions as code packages
Understanding code reusability
Defining a function
Accessing functions
Sending information to functions
Returning information from functions
Comparing function output
Getting User Input
Chapter 7: Making Decisions
Making Simple Decisions Using the if Statement
Understanding the if statement
Using the if statement in an application
Choosing Alternatives Using the if...else Statement
Understanding the if...else statement
Using the if...else statement in an application
Using the if...elif statement in an application
Using Nested Decision Statements
Using multiple if or if...else statements
Combining other types of decisions
Chapter 8: Performing Repetitive Tasks
Processing Data Using the for Statement
Understanding the for statement
Creating a basic for loop
Controlling execution with the break statement
Controlling execution with the continue statement
Controlling execution with the pass clause
Controlling execution with the else statement
Processing Data Using the while Statement
Understanding the while statement
Using the while statement in an application
Nesting Loop Statements
Chapter 9: Dealing with Errors
Knowing Why Python Doesn’t Understand You
Considering the Sources of Errors
Classifying when errors occur
Distinguishing error types
Catching Exceptions
Basic exception handling
Handling more specific to less specific exceptions
Nested exception handling
Raising Exceptions
Raising exceptions during exceptional conditions
Passing error information to the caller
Creating and Using Custom Exceptions
Using the finally Clause
Part III: Performing Common Tasks
Chapter 10: Interacting with Modules
Creating Code Groupings
Importing Modules
Using the import statement
Using the from...import statement
Finding Modules on Disk
Viewing the Module Content
Using the Python Module Documentation
Opening the pydoc application
Using the quick-access links
Typing a search term
Viewing the results
Chapter 11: Working with Strings
Understanding That Strings Are Different
Defining a character using numbers
Using characters to create strings
Creating Stings with Special Characters
Selecting Individual Characters
Slicing and Dicing Strings
Locating a Value in a String
Formatting Strings
Chapter 12: Managing Lists
Organizing Information in an Application
Defining organization using lists
Understanding how computers view lists
Creating Lists
Accessing Lists
Looping through Lists
Modifying Lists
Searching Lists
Sorting Lists
Working with the Counter Object
Chapter 13: Collecting All Sorts of Data
Understanding Collections
Working with Tuples
Working with Dictionaries
Creating and using a dictionary
Replacing the switch statement with a dictionary
Creating Stacks Using Lists
Working with queues
Working with deques
Chapter 14: Creating and Using Classes
Understanding the Class as a Packaging Method
Considering the Parts of a Class
Creating the class definition
Considering the built-in class attributes
Working with methods
Working with constructors
Working with variables
Using methods with variable argument lists
Overloading operators
Creating a Class
Using the Class in an Application
Extending Classes to Make New Classes
Building the child class
Testing the class in an application
Part IV: Performing Advanced Tasks
Chapter 15: Storing Data in Files
Understanding How Permanent Storage Works
Creating Content for Permanent Storage
Creating a File
Reading File Content
Updating File Content
Deleting a File
Chapter 16: Sending an E-Mail
Understanding What Happens When You Send E-mail
Viewing e-mail as you do a letter
Defining the parts of the envelope
Defining the parts of the letter
Creating the E-mail Message
Working with a text message
Working with an HTML message
Seeing the E-mail Output
Part V: The Part of Tens
Chapter 17: Ten Amazing Programming Resources
Working with the Python Documentation Online
Using the LearnPython.org Tutorial
Performing Web Programming Using Python
Getting Additional Libraries
Creating Applications Faster Using an IDE
Checking Your Syntax with Greater Ease
Using XML to Your Advantage
Getting Past the Common Python Newbie Errors
Understanding Unicode
Making Your Python Application Fast
Chapter 18: Ten Ways to Make a Living with Python
Working in QA
Becoming the IT Staff for a Smaller Organization
Performing Specialty Scripting for Applications
Administering a Network
Teaching Programming Skills
Helping People Decide on Location
Performing Data Mining
Interacting with Embedded Systems
Carrying Out Scientific Tasks
Performing Real-Time Analysis of Data
Chapter 19: Ten Interesting Tools
Tracking Bugs with Roundup Issue Tracker
Creating a Virtual Environment Using VirtualEnv
Installing Your Application Using PyInstaller
Building Developer Documentation Using pdoc
Developing Application Code Using Komodo Edit
Debugging Your Application Using pydbgr
Entering an Interactive Environment Using IPython
Testing Python Applications Using PyUnit
Tidying Your Code Using Isort
Providing Version Control Using Mercurial
Chapter 20: Ten Libraries You Need to Know About
Developing a Secure Environment Using PyCrypto
Interacting with Databases Using SQLAlchemy
Seeing the World Using Google Maps
Adding a Graphical User Interface Using TkInter
Providing a Nice Tabular Data Presentation Using PrettyTable
Enhancing Your Application with Sound Using PyAudio
Manipulating Images Using PyQtGraph
Locating Your Information Using IRLib
Creating an Interoperable Java Environment Using JPype
Accessing Local Network Resources Using Twisted Matrix
Accessing Internet Resources Using Libraries
About the Author
Cheat Sheet
Table of Contents
Begin Reading
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
383
385
387
388
Quick! Which programming language will get you up and running writing applications on every popular platform around? Give up? Yes, it’s Python. The amazing thing about Python is that you really can write an application on one platform and use it on every other platform that you need to support. Unlike the other programming languages that promised to provide platform independence, Python really does make that independence possible. In this case, the promise is as good as the result you get.
Python emphasizes code readability and a concise syntax that lets you write applications using fewer lines of code than other programming languages require. In addition, because of the way Python works, you find it used in all sorts of fields that are filled with nonprogrammers. Some people view Python as a scripted language, but it really is so much more. (Chapter provides you with just an inkling of the occupations that rely on Python to make things work.)
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!