Python: An Introduction to Programming, 2nd Edition
- Length: 572 pages
- Edition: 2
- Language: English
- Publisher: Mercury Learning and Information
- Publication Date: 2021-03-30
- ISBN-10: 1683926242
- ISBN-13: 9781683926245
- Sales Rank: #1346452 (See Top 100 Books)
This book is an introduction to programming concepts that uses Python 3 as the target language. It follows a practical just in time presentation – material is given to the student when it is needed. Many examples will be based on games because Python has become the language of choice for basic game development. Designed as a year 1 textbook for introduction to programming classes or for the hobbyist who wants to learn the fundamentals of programming, the text assumes no programming experience.
FEATURES
- Introduces programming concepts using Python 3
- Covers basic computer concepts such as loops, strings, functions, files, graphics, multimedia, algorithms, classes, writing code, etc.
- Develops graphics, exercises, and user interface using Pygame
- Includes many examples based on video game development
- 4 color throughout with game demos on the companion files
- New chapters on parsing (14) and graphics (15)
- Instructor ancillaries for use as a textbook
TABLE OF CONTENTS
0: Modern Computers.
1: Computers and Programming.
2: Repetition.
3: Sequences.
4: Functions.
5: Files.
6: Classes.
7: Graphics.
8: Manipulating Data.
9: Multimedia.
10: Basic Algorithms.
11: Programming for the Sciences.
12: How to Write Good Programs.
13: Communicating with the Outside World.
14: Parsing.
15: Communicating Using Graphics.
ABOUT THE AUTHOR
J. R. Parker, PhD is a professor of Art Digital Media at the University of Calgary. His areas of research include computer games and media art, computer simulation, and educational technology. Dr. Parker is the author of Game Development Using Python, 2/E (Mercury Learning) and The Guide to Simulations and Games (Wiley).
Cover Title Copyright Contents Preface Chapter 0 Modern Computers 0.1 Calculations by Machine 0.2 How Computers Work and Why We M ade Them 0.2.1 Numbers Example: Base 4 Convert Binary Numbers to Decimal Convert Decimal Numbers to Binary Arithmetic in Binary 0.2.2 Memory 0.2.3 Stored Programs 0.3 Computer Systems Are Built in Layers 0.3.1 Assemblers and Compilers 0.3.2 Graphical User Interfaces (GUIs) Widgets 0.4 Computer Networks 0.4.1 Internet 0.4.2 World Wide Web 0.5 Representation 0.6 Summary Chapter 1 Computers and Programming 1.1 Solving a Problem Using a Computer 1.2 Executing Python 1.3 Guess A Number 1.4 Rock-Paper-Scissors 1.5 Solving the Guess a Number Problem 1.6 Solving the Rock-Paper-Scissors Problem 1.6.1 Variables and Values – Experimenting with the Graphical User Interface 1.6.2 Exchanging Information with the Computer 1.6.3 Example 1: Draw a Circle Using Characters 1.6.4 Strings, Integers, and Real Numbers 1.6.5 Number Bases 1.6.6 Example 2: Compute the Circumference of any Circle 1.6.7 Guess a Number Again 1.7 IF Statements 1.7.1 Else 1.8 Documentation 1.9 Rock-Paper-Scissors Again 1.10 Types Are Dynamic (Advanced) 1.11 Summary Chapter 2 Repetition 2.1 The WHILE Statement 2.1.1 The Guess-A-Number Program Yet Again 2.1.2 Modifying the Game 2.2 Rock-Paper-Scissors Yet Again 2.2.1 Random Numbers 2.3 Counting Loops 2.4 Prime or Non-Prime 2.4.1 Exiting from a Loop 2.4.2 Else 2.5 Loops That are Nested 2.6 Draw a Histogram 2.7 Loops in General 2.8 Exceptions and Errors 2.8.1 Problem: A Final Look at Guess a Number 2.9 Summary Chapter 3 Sequences: Strings, Tuples, and Lists 3.1 Strings 3.1.1 Comparing Strings 3.1.2 Slicing – Extracting Parts of Strings 3.1.3 Editing Strings 3.1.4 String Methods 3.1.5 Spanning Multiple Lines 3.1.6 For Loops Again 3.2 The Type Bytes 3.3 Tuples 3.3.1 Tuples in For Loops 3.3.2 Membership 3.3 Delete 3.3.4 Update 3.3.5 Tuple Assignment 3.3.6 Built-In Functions for Tuples 3.4 Lists 3.4.1 Editing Lists 3.4.2 Insert 3.4.3 Append 3.4.4 Extend 3.4.5 Remove 3.4.6 Index 3.4.7 Pop 3.4.8 Sort 3.4.9 Reverse 3.4.10 Count 3.4.11 List Comprehension 3.4.12 Lists and Tuples 3.4.13 Exceptions 3.5 Set Types 3.5.1 Example: Craps 3.6 Summary Chapter 4 Functions 4.1 Function Definition: Syntax and Semantics 4.1.1 Problem: Use poundn to Draw a Histogram 4.1.2 Problem: Generalize the Histogram Code for Other Years 4.2 Function Execution 4.2.1 Returning a Value 4.2.2 Parameters 4.2.3 Default Parameters 4.2.4 None 4.2.5 Example: The Game of Sticks 4.2.6 Scope 4.2.7 Variable Parameter Lists 4.2.8 Variables as Functions Example: Find the maximum value of a function 4.2.9 Functions as Return Values 4.3 Recursion 4.3.1 Avoiding Infinite Recursion 4.4 Creating Python Modules 4.5 Program Design Using Functions – Example: The Game of Nim 4.5.1 The Development Process Exposed 4.6 Summary Chapter 5 Files: Input and Output 5.1 What Is a File? A Little “Theory” 5.1.1 How Are Files Stored on a Disk? 5.1.2 File Access is Slow 5.2 Keyboard Input 5.2.1 Problem: Read a Number from the Keyboard and Divide It by 2 5.3 Using Files in Python: Less Theory, More Practice 5.3.1 Open a File File Not Found Exceptions 5.3.2 Reading from Files End of File Common File Input Operations CSV Files The With Statement 5.4 Writing to Files Example: Write a Table of Squares to a File 5.4.1 Appending Data to a File Example: Append another 20 squares to the table of squares file 5.5 Summary Chapter 6 Classes 6.1 A Casual Introduction to Classes 6.2 Classes and Data Types 6.3 Classes as Encapsulated Modules 6.4 Classes as Data Abstractions 6.5 The Python Class – Syntax and Semantics 6.5.1 A Really Simple Class 6.5.2 Encapsulation 6.6 Classes and Data Types Again 6.6.1 Example: A Deck of Cards 6.6.2 A Bouncing Ball 6.6.3 Cat-A-Pult Basic Design Detailed Design 6.7 Subclasses and Inheritance 6.7.1 Non-Trivial Example: Objects in a Video Game 6.8 Duck Typing 6.5 Summary Chapter 7 Graphics 7.1 Introduction to Graphics Programming 7.2 Graphics in Python–Pygame 7.3 Initializing Pygame 7.3.1 Colors 7.4 The Event LOOP 7.5 Drawing Example: Create a Page of Note Paper Example: Creating a Color Gradient 7.5.1 Lines and Curves Example: Note Paper Again 7.6 Acrs and Curves 7.6.1 Polygons 7.6.2 Text 7.6.3 Example: A Histogram 7.6.4 Example: A Pie Chart 7.6.5 Images Pixles, Again Example: Identifying a green car Example: Thresholding Transparency 7.6.6 Generative Art 7.7 Summary Chaper 8 Manipulating Data 8.1 Dictionaries 8.1.1 Example: A Naive Latin – English Translation 8.1.2 Functions for Dictionaries 8.1.3 Dictionaries and Loops 8.2 Arrays 8.3 Formatted Text, Formatted I/O 8.3.1 Example: NASA Meteorite Landing Data 8.4 Advanced Data Files 8.4.1 Binary Files Example: Create a File of Integers 8.4.2 The Struct Module Example: A Video Game High Score File 8.4.3 Random Access Example: Maintaining the High Score File in Order 8.5 Standard File Types 8.5.1 Image Files 8.5.2 GIF 8.5.3 JPEG 8.5.4 TIFF 8.5.5 PNG 8.5.6 Sound Files 8.5.7 WAV 8.5.8 Other Files 8.5.9 HTML 8.5.10 EXE 8.6 Summary Chapter 9 Multimedia 9.1 Mouse Interaction Example: Draw a Circle at the Mouse Cursor Example: Change Background Color Using the Mouse 9.1.1 Mouse Buttons Example: Draw Lines Using the Mouse Example: A Button 9.2 The Keyboard Example: Pressing a “q” Creates a Random Circle Example: Reading a Character String 9.3 Animaiton 9.3.1 Object Animation Example: A Ball in a Box Example: Many Balls in a Box 9.3.2 Frame Animation Example: Read Frames and Play Them Back as an Animation Example: Simulation of the Space Shuttle Control Console (A Class That Will Draw an Animation at a Specific Location) 9.4 RGBA Colors – Transparency 9.5 Sound Example: Play a Sound Example: Control Volume Using the Keyboard Example: Play a Sound Effect at the Right Moment: Bounces Music 9.7 Summary Chapter 10 Basic Algorithms 10.1 Sorting 10.1.1 Selection Sort 10.1.2 Merge Sort 10.2 Searching 10.2.1 Timings 10.2.2 Linear Search 10.2.3 Binary Search 10.3 Random Number Generation 10.3.1 Linear Congruential Method 10.4 Cryptography 10.4.1 One-Time Pad 10.4.2 Public Key Encryption (RSA) 10.4.3 Example: Encrypt the Message “Depart at Dawn” Using RSA 10.5 Compression 10.5.1 Huffman Encoding 10.5.2 LZW Compression 10.6 Hashing 10.6.1 DJB2 10.6.2 SDBM 10.7 Summary Chapter 11 Programming for the Sciences 11.1 Finding Roots of Equations 11.2 Differentiation 11.3 Integration 11.4 Optimization: Finding Maxima and Minima 11.4.1 Newton Again 11.4.2 Fitting Data to Curves – Regression 11.4.3 Evolutionary Methods 11.5 Longest Common Subsequence (Edit Distance) 11.5.1 Determining Longest Common Subsequence (LCS) 11.5.2 NumPy 11.5.3 One Dimensional Arrays (Vectors) 11.5.4 Two Dimensional Arrays (Matrices) 11.5.5 Sample Problem: Finding Paths 11.5.6 Linear Regression Again 11.6 Summary Chapter 12 How to Write Good Programs 12.1 Procedural Programming – Word Processing 12.1.1 Top-Down 12.1.2 Centering 12.1.3 Right Justification 12.1.4 Other Commands 12.2 Object Oriented Programming – Breakout 12.3 Describing the Problem as a Process 12.3.1 Initial Coding for a Tile 12.3.2 Initial Coding for the Paddle 12.3.3 Initial Coding for the Ball 12.3.4 Collecting the Classes 12.3.5 Developing the Paddle 12.3.6 Ball and Tile Collisions 12.3.7 Ball and Paddle Collisions 12.3.8 Finishing the Game 12.4 Rules for Programmers 12.5 Summary Chapter 13 Communicating with the Outside World 13.1 EMail Example: Send an email 13.1.1 Reading email 13.1.2 Example: Display the Subject Headers for Emails in Inbox 13.2 FTP 13.2.1 Example: Download and Display the README File from an FTP Site 13.3 Communication Between Processes 13.3.1 Example: A Server That Calculates Squares 13.4 Twitter Example: Connect to the Twitter Stream and Print Specific Messages 13.5 Communicating with Other Languages 13.5.1 Example: Find Two Large Relatively Prime Numbers 13.6 Summary Chaper 14 Parsing–The Structure of Data 14.1 Grammars 14.2 PyJ and Julia 14.3 Language Symbols and Scanning 14.4 Parsing a Programming Language 14.5 WHILE Statements 14.6 FOR Statements 14.7 IF Statements 14.8 Expressions 14.9 Functions 14.10 Examples Chatper 15 Communicating Using Graphics: Windows, User Interfaces, and Pygame 15.1 A Paint Program Interface 15.2 Building the Mondrean Interface 15.3 Selecting 15.4 The Buttons Drawing 15.5 Images and Surfaces 15.6 Stacks: Undraw and Redraw 15.7 Color Selection 15.8 Image File Selection Index
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.