(eBook PDF) Practice of Computing Using Python, The 3rd Editioninstant download
(eBook PDF) Practice of Computing Using Python, The 3rd Editioninstant download
https://ebookluna.com/product/ebook-pdf-practice-of-computing-
using-python-the-3rd-edition/
https://ebookluna.com/product/ebook-pdf-introduction-to-programming-using-
python-an-1/
https://ebookluna.com/product/ebook-pdf-numerical-analysis-mathematics-of-
scientific-computing-3rd/
https://ebookluna.com/product/ebook-pdf-the-practice-of-creative-
writings-3rd-edition/
https://ebookluna.com/download/the-physics-of-computing-ebook-pdf/
(eBook PDF) The Doctor of Nursing Practice Essentials 3rd Edition
https://ebookluna.com/product/ebook-pdf-the-doctor-of-nursing-practice-
essentials-3rd-edition/
https://ebookluna.com/product/ebook-pdf-python-programming-in-context-3rd-
edition/
https://ebookluna.com/product/python-programming-in-context-3rd-edition-
ebook-pdf/
(eBook PDF) The Speaker: The Tradition and Practice of Public Speaking 3rd
https://ebookluna.com/product/ebook-pdf-the-speaker-the-tradition-and-
practice-of-public-speaking-3rd/
(eBook PDF) The Nurse, The Math, The Meds: Drug Calculations Using
Dimensional Analysis 3rd Edition
https://ebookluna.com/product/ebook-pdf-the-nurse-the-math-the-meds-drug-
calculations-using-dimensional-analysis-3rd-edition/
THE PRACTICE OF COMPUTING USING
3RD EDITION
WILLIAM RICHARD
PUNCH • ENBODY
C O N T E N T S
•
VIDEONOTES xxiv
PREFACE xxv
PREFACE TO THE SECOND EDITION xxix
1.0.1 Data Manipulation xxx
1.0.2 Problem Solving and Case Studies xxx
1.0.3 Code Examples xxx
1.0.4 Interactive Sessions xxxi
1.0.5 Exercises and Programming Projects xxxi
1.0.6 Self-Test Exercises xxxi
1.0.7 Programming Tips xxxi
vii
viii CONTENTS
P A R T 2 S TA RT I N G T O P R O G R A M 35
Chapter 1 Beginnings 37
1.1 Practice, Practice, Practice 37
1.2 QuickStart, the Circumference Program 38
1.2.1 Examining the Code 40
1.3 An Interactive Session 42
1.4 Parts of a Program 43
1.4.1 Modules 43
1.4.2 Statements and Expressions 43
1.4.3 Whitespace 45
1.4.4 Comments 46
1.4.5 Special Python Elements: Tokens 46
1.4.6 Naming Objects 48
1.4.7 Recommendations on Naming 49
1.5 Variables 49
1.5.1 Variable Creation and Assignment 50
1.6 Objects and Types 53
1.6.1 Numbers 55
1.6.2 Other Built-In Types 57
1.6.3 Object Types: Not Variable Types 58
1.6.4 Constructing New Values 60
CONTENTS ix
1.7 Operators 61
1.7.1 Integer Operators 61
1.7.2 Floating-Point Operators 64
1.7.3 Mixed Operations 64
1.7.4 Order of Operations and Parentheses 65
1.7.5 Augmented Assignment Operators: A Shortcut! 66
1.8 Your First Module, Math 68
1.9 Developing an Algorithm 69
1.9.1 New Rule—Testing 73
1.10 Visual Vignette: Turtle Graphics 74
1.11 What’s Wrong with My Code? 75
Chapter 2 Control 87
2.1 QuickStart Control 87
2.1.1 Selection 87
2.1.2 Booleans for Decisions 89
2.1.3 The if Statement 89
2.1.4 Example: What Lead Is Safe in Basketball? 92
2.1.5 Repetition 96
2.1.6 Example: Finding Perfect Numbers 100
2.1.7 Example: Classifying Numbers 105
2.2 In-Depth Control 109
2.2.1 True and False: Booleans 109
2.2.2 Boolean Variables 110
2.2.3 Relational Operators 110
2.2.4 Boolean Operators 115
2.2.5 Precedence 116
2.2.6 Boolean Operators Example 117
2.2.7 Another Word on Assignments 120
2.2.8 The Selection Statement for Decisions 122
2.2.9 More on Python Decision Statements 122
2.2.10 Repetition: the while Statement 126
2.2.11 Sentinel Loop 136
2.2.12 Summary of Repetition 136
2.2.13 More on the for Statement 137
2.2.14 Nesting 140
2.2.15 Hailstone Sequence Example 142
2.3 Visual Vignette: Plotting Data with Pylab 143
2.3.1 First Plot and Using a List 144
2.3.2 More Interesting Plot: A Sine Wave 145
x CONTENTS
P A R T 3 D AT A S T R U C T U R E S A N D F U N C T I O N S 187
Chapter 4 Working with Strings 189
4.1 The String Type 190
4.1.1 The Triple-Quote String 190
4.1.2 Nonprinting Characters 191
4.1.3 String Representation 191
4.1.4 Strings as a Sequence 192
4.1.5 More Indexing and Slicing 193
4.1.6 Strings Are Iterable 198
CONTENTS xi
P A R T 4 C L A S S E S , M A K I N G Y O U R O W N D AT A S T R U C T U R E S
AND ALGORITHMS 527
Chapter 11 Introduction to Classes 529
11.1 QuickStart: Simple Student Class 529
11.2 Object-Oriented Programming 530
11.2.1 Python Is Object-Oriented! 530
11.2.2 Characteristics of OOP 531
11.3 Working with OOP 531
11.3.1 Class and Instance 531
11.4 Working with Classes and Instances 532
11.4.1 Built-In Class and Instance 532
11.4.2 Our First Class 534
11.4.3 Changing Attributes 536
11.4.4 The Special Relationship Between an Instance and
Class: instance-of 537
11.5 Object Methods 540
11.5.1 Using Object Methods 540
11.5.2 Writing Methods 541
11.5.3 The Special Argument self 542
11.5.4 Methods Are the Interface to a Class Instance 544
11.6 Fitting into the Python Class Model 545
11.6.1 Making Programmer-Defined Classes 545
11.6.2 A Student Class 545
11.6.3 Python Standard Methods 546
11.6.4 Now There Are Three: Class Designer, Programmer,
and User 550
11.7 Example: Point Class 551
11.7.1 Construction 553
11.7.2 Distance 553
11.7.3 Summing Two Points 553
11.7.4 Improving the Point Class 554
11.8 Python and OOP 558
11.8.1 Encapsulation 558
11.8.2 Inheritance 559
11.8.3 Polymorphism 559
11.9 Python and Other OOP Languages 559
11.9.1 Public versus Private 559
11.9.2 Indicating Privacy Using Double Underscores (__) 560
CONTENTS xvii
APPENDICES 753
Appendix A Getting and Using Python 753
A.1 About Python 753
A.1.1 History 753
A.1.2 Python 3 753
A.1.3 Python Is Free and Portable 754
A.1.4 Installing Anaconda 756
A.1.5 Starting Our Python IDE: Spyder 756
A.1.6 Working with Python 757
A.1.7 Making a Program 760
A.2 The IPython Console 762
A.2.1 Anatomy of an iPython Session 763
A.2.2 Your Top Three iPython Tips 764
A.2.3 Completion and the Tab Key 764
A.2.4 The ? Character 766
A.2.5 More iPython Tips 766
A.3 Some Conventions for This Book 769
A.3.1 Interactive Code 770
A.3.2 Program: Written Code 770
A.3.3 Combined Program and Output 770
A.4 Summary 771
Appendix B Simple Drawing with Turtle Graphics 773
B.0.1 What Is a Turtle? 773
B.0.2 Motion 775
B.0.3 Drawing 775
B.0.4 Color 777
B.0.5 Drawing with Color 779
B.0.6 Other Commands 781
B.1 Tidbits 783
B.1.1 Reset/Close the Turtle Window 783
Appendix C What’s Wrong with My Code? 785
C.1 It’s Your Fault! 785
C.1.1 Kinds of Errors 785
C.1.2 “Bugs” and Debugging 787
C.2 Debugging 789
C.2.1 Testing for Correctness 789
C.2.2 Probes 789
C.2.3 Debugging with Spyder Example 1 789
C.2.4 Debugging Example 1 Using print() 793
Discovering Diverse Content Through
Random Scribd Documents
unembarrassed brow of superior bravery, made a long pause, and
dragged out the words,
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookluna.com