Instant Download Automate The Boring Stuff With Python Practical Programming For Total Beginners 2nd Edition Al Sweigart PDF All Chapter
Instant Download Automate The Boring Stuff With Python Practical Programming For Total Beginners 2nd Edition Al Sweigart PDF All Chapter
com
OR CLICK BUTTON
DOWLOAD NOW
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://ebookmeta.com/product/automate-the-boring-stuff-with-
python-practical-programming-for-total-beginners-1st-edition-al-
sweigart/
https://ebookmeta.com/product/automate-the-boring-stuff-with-
python-practical-programming-for-total-beginners-1st-edition-al-
sweigart-3/
https://ebookmeta.com/product/automate-the-boring-stuff-with-
python-practical-programming-for-total-beginners-1st-edition-al-
sweigart-2/
https://ebookmeta.com/product/automate-the-boring-stuff-with-
python-practical-programming-for-total-beginners-1st-edition-al-
sweigart-4/
Python Programming for Beginners 2023rd Edition Knowles
https://ebookmeta.com/product/python-programming-for-
beginners-2023rd-edition-knowles/
https://ebookmeta.com/product/cracking-codes-with-python-an-
introduction-to-building-and-breaking-ciphers-supplementary-
materials-1st-edition-al-sweigart/
https://ebookmeta.com/product/the-big-book-of-small-python-
projects-81-easy-practice-programs-1st-edition-al-sweigart/
https://ebookmeta.com/product/a-beginners-guide-to-
python-3-programming-2nd-edition-john-hunt/
https://ebookmeta.com/product/python-programming-for-beginners-
the-most-comprehensive-programming-guide-to-become-a-python-
expert-from-scratch-in-no-time-reed/
AUTOMATE THE BORING STUFF WITH
PYTHON
2ND EDITION
by Al Sweigart
San Francisco
AUTOMATE THE BORING STUFF WITH PYTHON, 2ND EDITION.
Copyright © 2020 by Al Sweigart.
All rights reserved. No part of this work may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying, recording, or
by any information storage or retrieval system, without the prior written permission of
the copyright owner and the publisher.
Fifth printing
25 24 23 22 21 5 6 7 8 9
ISBN-10: 1-59327-992-2
ISBN-13: 978-1-59327-992-9
The Library of Congress Control Number for the first edition is: 2014953114
No Starch Press and the No Starch Press logo are registered trademarks of No Starch
Press, Inc. Other product and company names mentioned herein may be the
trademarks of their respective owners. Rather than use a trademark symbol with every
occurrence of a trademarked name, we are using the names only in an editorial fashion
and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The information in this book is distributed on an “As Is” basis, without warranty.
While every precaution has been taken in the preparation of this work, neither the
author nor No Starch Press, Inc. shall have any liability to any person or entity with
respect to any loss or damage caused or alleged to be caused directly or indirectly by
the information contained in it.
INTRODUCTION
Whom Is This Book For?
Conventions
What Is Programming?
What Is Python?
Programmers Don’t Need to Know Much Math
You Are Not Too Old to Learn Programming
Programming Is a Creative Activity
About This Book
Downloading and Installing Python
Downloading and Installing Mu
Starting Mu
Starting IDLE
The Interactive Shell
Installing Third-Party Modules
How to Find Help
Asking Smart Programming Questions
Summary
1
PYTHON BASICS
Entering Expressions into the Interactive Shell
The Integer, Floating-Point, and String Data Types
String Concatenation and Replication
Storing Values in Variables
Assignment Statements
Variable Names
Your First Program
Dissecting Your Program
Comments
The print() Function
The input() Function
Printing the User’s Name
The len() Function
The str(), int(), and float() Functions
Summary
Practice Questions
2
FLOW CONTROL
Boolean Values
Comparison Operators
Boolean Operators
Binary Boolean Operators
The not Operator
Mixing Boolean and Comparison Operators
Elements of Flow Control
Conditions
Blocks of Code
Program Execution
Flow Control Statements
if Statements
else Statements
elif Statements
while Loop Statements
break Statements
continue Statements
for Loops and the range() Function
Importing Modules
from import Statements
Ending a Program Early with the sys.exit() Function
A Short Program: Guess the Number
A Short Program: Rock, Paper, Scissors
Summary
Practice Questions
3
FUNCTIONS
def Statements with Parameters
Define, Call, Pass, Argument, Parameter
Return Values and return Statements
The None Value
Keyword Arguments and the print() Function
The Call Stack
Local and Global Scope
Local Variables Cannot Be Used in the Global Scope
Local Scopes Cannot Use Variables in Other Local Scopes
Global Variables Can Be Read from a Local Scope
Local and Global Variables with the Same Name
The global Statement
Exception Handling
A Short Program: Zigzag
Summary
Practice Questions
Practice Projects
The Collatz Sequence
Input Validation
4
LISTS
The List Data Type
Getting Individual Values in a List with Indexes
Negative Indexes
Getting a List from Another List with Slices
Getting a List’s Length with the len() Function
Changing Values in a List with Indexes
List Concatenation and List Replication
Removing Values from Lists with del Statements
Working with Lists
Using for Loops with Lists
The in and not in Operators
The Multiple Assignment Trick
Using the enumerate() Function with Lists
Using the random.choice() and random.shuffle() Functions
with Lists
Augmented Assignment Operators
Methods
Finding a Value in a List with the index() Method
Adding Values to Lists with the append() and insert() Methods
Removing Values from Lists with the remove() Method
Sorting the Values in a List with the sort() Method
Reversing the Values in a List with the reverse() Method
Example Program: Magic 8 Ball with a List
Sequence Data Types
Mutable and Immutable Data Types
The Tuple Data Type
Converting Types with the list() and tuple() Functions
References
Identity and the id() Function
Passing References
The copy Module’s copy() and deepcopy() Functions
A Short Program: Conway’s Game of Life
Summary
Practice Questions
Practice Projects
Comma Code
Coin Flip Streaks
Character Picture Grid
5
DICTIONARIES AND STRUCTURING DATA
The Dictionary Data Type
Dictionaries vs. Lists
The keys(), values(), and items() Methods
Checking Whether a Key or Value Exists in a Dictionary
The get() Method
The setdefault() Method
Pretty Printing
Using Data Structures to Model Real-World Things
A Tic-Tac-Toe Board
Nested Dictionaries and Lists
Summary
Practice Questions
Practice Projects
Chess Dictionary Validator
Fantasy Game Inventory
List to Dictionary Function for Fantasy Game Inventory
6
MANIPULATING STRINGS
Working with Strings
String Literals
Indexing and Slicing Strings
The in and not in Operators with Strings
Putting Strings Inside Other Strings
Useful String Methods
The upper(), lower(), isupper(), and islower() Methods
The isX() Methods
The startswith() and endswith() Methods
The join() and split() Methods
Splitting Strings with the partition() Method
Justifying Text with the rjust(), ljust(), and center() Methods
Removing Whitespace with the strip(), rstrip(), and lstrip()
Methods
Numeric Values of Characters with the ord() and chr() Functions
Copying and Pasting Strings with the pyperclip Module
Project: Multi-Clipboard Automatic Messages
Step 1: Program Design and Data Structures
Step 2: Handle Command Line Arguments
Step 3: Copy the Right Phrase
Project: Adding Bullets to Wiki Markup
Step 1: Copy and Paste from the Clipboard
Step 2: Separate the Lines of Text and Add the Star
Step 3: Join the Modified Lines
A Short Progam: Pig Latin
Summary
Practice Questions
Practice Projects
Table Printer
Zombie Dice Bots
CHAPITRE LXXVIII.
CHAPITRE LXXIX.
CHAPITRE LXXX.
CHAPITRE LXXXI.
CHAPITRE LXXXII.
CHAPITRE LXXXIII.
Updated editions will replace the previous one—the old editions will
be renamed.
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.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.