Home > Store

Python Without Fear

Register your product to gain access to bonus material or receive a coupon.

Python Without Fear

Best Value Purchase

Book + eBook Bundle

  • Your Price: $43.19
  • List Price: $71.98
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

More Purchase Options

Book

  • Your Price: $31.99
  • List Price: $39.99
  • Usually ships in 24 hours.

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

About

Features

  • By Brian Overland, author of the best-selling C++ Without Fear
  • Takes readers “under the covers” with Python, so they understand why it works the way it does
  • Makes learning Python fun, by showing how to use it to solve challenging puzzles and win fascinating games
  • Especially well-designed for programmers moving to Python from languages such as C, C++, Visual Basic, or Java

Description

  • Copyright 2018
  • Dimensions: 7" x 9-1/8"
  • Pages: 464
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-468747-7
  • ISBN-13: 978-0-13-468747-6

Praise for this book, Python Without Fear

“This is really a great book. I wish I’d had it when I was learning Python.”

–John M. Wargo, author of Apache Cordova 4 Programming

Praise for the previous book in the series, C++ Without Fear

“I’m in love with your C++ Without Fear book. It keeps me awake for hours during the night. Thanks to you, I got most of the idea in just a few hours.”

–Laura Viral, graduate physics student at CERN and Istanbul, Turkey

“It’s hard to tell where I began and ended with your book. I felt like I woke up and literally knew how to write C++

code. I can’t overstate the confidence you gave me.”

– Danny Grady, senior programmer/analyst at a Fortune 500 Company

Whether you’re new to programming or moving from another language, Python Without Fear will quickly make you productive! Brian Overland’s unique approach to Python includes:

  • Taking you by the hand while teaching topics from the very basics to intermediate and advanced features of Python
  • Teaching by examples that are explained line by line
  • Heavy emphasis on examples that are fun and useful, including games, graphics, database applications, file storage, puzzles, and more!
  • How to think “Pythonically” and avoid common “gotchas”

Register your product at informit.com/register for convenient access to downloads, updates, and/or corrections as they become available.

Downloads

Downloads

Download the sample code (26 KB .zip)

Sample Content

Online Sample Chapter

Writing Functions in Python

Sample Pages

Download the sample pages (includes Chapter 3 and the Index)

Table of Contents

Preface xvii

Acknowledgments xxi

Author Bio xxiii

Chapter 1: Meet the Python 1

A Brief History of Python 1

How Python Is Different 2

How This Book Works 3

Installing Python 4

Begin Using Python with IDLE 6

Correcting Mistakes from Within IDLE 6

Dealing with Ends of Lines 7

Additional Help: Online Sources 8

Chapter 2: A Python Safari: Numbers 9

Python and Numbers 9

Python and Floating-Point Numbers 14

Assigning Numbers to Variables 17

Variable-Naming Conventions in This Book 23

Some Python Shortcuts 23

Chapter 2 Summary 26

Chapter 3: Your First Programs 29

Temperatures Rising? 29

Putting in a Print Message 35

Syntax Summaries 36

Getting String Input 41

Getting Numeric Input 43

Formatted Output String 46

Chapter 3 Summary 50

Chapter 4: Decisions and Looping 53

Decisions Inside a Computer Program 53

Conditional and Boolean Operators 55

The if, elif, and else Keywords 56

while: Looping the Loop 60

“Give Me a break” Statement 70

Chapter 4 Summary 75

Chapter 5: Python Lists 77

The Python Way: The World Is Made of Collections 77

Processing Lists with for 80

Modifying Elements with for (You Can't!) 82

Indexing and Slicing 85

Copying Data to Slices 88

Ranges 89

List Functions and the in Keyword 97

Chapter 5 Summary 99

Chapter 6: List Comprehension and Enumeration 101

Indexes and the enumerate Function 101

The Format String Method Revisited 103

Simple List Comprehension 106

“Two-Dimensional” List Comprehension 112

List Comprehension with Conditional 114

Chapter 6 Summary 123

Chapter 7: Python Strings 125

Creating a String with Quote Marks 125

Indexing and “Slicing” 127

String/Number Conversions 130

Stripping for Fun and Profit 135

Let’s Split: The split Method 138

Building Strings with Concatenation (+) 139

The join Method 143

Chapter 7 Summary 144

Chapter 8: Single-Character Ops 147

Naming Conventions in This Chapter 147

Accessing Individual Characters (A Review) 148

Getting Help with String Methods 148

Testing Uppercase vs. Lowercase 149

Converting Case of Letters 150

Testing for Palindromes 151

Converting to ASCII Code 159

Converting ASCII to Character 160

Chapter 8 Summary 166

Chapter 9: Advanced Function Techniques 167

Multiple Arguments 167

Returning More Than One Value 168

Arguments by Name 173

Default Arguments 174

Importing Functions from Modules 178

Chapter 9 Summary 185

Chapter 10: Local and Global Variables 187

Local Variables, What Are They Good For? 187

Locals vs. Globals 188

Introducing the global Keyword 190

The Python “Local Variable Trap” 190

Chapter 10 Summary 204

Chapter 11: File Ops 207

Text Files vs. Binary Files 207

The Op System (os) Module 208

Open a File 211

Let’s Write a Text File 213

Read a Text File 216

Files and Exception Handling 217

Other File Modes 223

Chapter 11 Summary 224

Chapter 12: Dictionaries and Sets 227

Why Do We Need Dictionaries, Ms. Librarian? 227

Adding and Changing Key-Value Pairs 229

Accessing Values 230

Searching for Keys 231

Converting Dictionaries to Lists 235

All About Sets 241

Operations on Sets 242

Chapter 12 Summary 246

Chapter 13: Matrixes: 2-D Lists 249

Simple Matrixes 249

Accessing Elements 250

Irregular Matrixes and Length of a Row 251

Multiplication (*) and Lists 252

The Python Matrix Problem 253

How to Create N*M Matrixes: The Solution 254

How to Rotate a Matrix 261

Chapter 13 Summary 268

Chapter 14: Winning at Tic-Tac-Toe 271

Design of a Tic-Tac-Toe Board 271

Plan of This Chapter 273

Python One-Line if/else 274

The count Method for Lists 279

Introducing the Computer Player 285

Chapter 14 Summary 294

Chapter 15: Classes and Objects I 295

What’s an Object? 295

Classes in Python 296

The All-Important _ _init_ Method 301

Design for a Database Class 303

Defining Other Methods 309

Design for a Point3D Class 310

Point3D Class and Default Arguments 312

Three-Dimensional Tic-Tac-Toe 312

Chapter 15 Summary 318

Chapter 16: Classes and Objects II 321

Getting Help from Doc Strings 321

Function Typing and “Overloading” 323

Variable-Length Argument Lists 326

Inheritance 331

The Fraction Class 333

Class Variables and Methods 337

Instance Variables as “Default” Values 339

Chapter 16 Summary 344

Chapter 17: Conway’s Game of Life 347

Game of Life: The Rules of the Game 348

Generating the Neighbor Count 350

Design of the Program 352

Moving the Matrix Class to a Module 354

The Famous Slider Pattern 358

Chapter 17 Summary 364

Chapter 18: Advanced Pythonic Techniques 367

Generators 367

Exploiting the Power of Generators 369

Properties 375

Decorators: Functions Enclosing Other Functions 382

Python Decoration 385

Chapter 18 Summary 389

Appendix A: Python Operator Precedence Table 391

Appendix B: Summary of Most Important Formatting Rules for Python 3.0 393

1. Formatting Ordinary Text 393

2. Formatting Arguments 393

3. Specifying Order of Arguments 393

4. Right Justification Within Field of Size N 394

5. Left Justification Within Field of Size N 394

6. Truncation: Limit Size of Print Field 394

7. Combined Truncation and Justification 395

8. Length and Precision of Floating-Point Numbers 395

9. The Padding Character 395

Appendix C: Glossary 397

Index 407

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020