Head First Python
THIRD EDITION
A Learner’s Guide to the Fundamentals of Python
Programming, A Brain-Friendly Guide
With Early Release ebooks, you get books in their earliest form—the
author’s raw and unedited content as they write—so you can take
advantage of these technologies long before the official release of these
titles.
Paul Barry
Head First Python
by Paul Barry
Copyright © 2023 Paul Barry. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Acquisitions Editor: Suzanne McQuade
Development Editor: Melissa Potter
Production Editor: Beth Kelly
Copyeditor: FILL IN COPYEDITOR
Proofreader: FILL IN PROOFREADER
Indexer: FILL IN INDEXER
Interior Designer: David Futato
Cover Designer: Karen Montgomery
Illustrator: Kate Dullea
August 2023: Third Edition
Revision History for the Early Release
2023-02-08: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492051299 for release
details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Head
First Python, the cover image, and related trade dress are trademarks of
O’Reilly Media, Inc.
The views expressed in this work are those of the author and do not
represent the publisher’s views. While the publisher and the author have
used good faith efforts to ensure that the information and instructions
contained in this work are accurate, the publisher and the author disclaim all
responsibility for errors or omissions, including without limitation
responsibility for damages resulting from the use of or reliance on this
work. Use of the information and instructions contained in this work is at
your own risk. If any code samples or other technology this work contains
or describes is subject to open source licenses or the intellectual property
rights of others, it is your responsibility to ensure that your use thereof
complies with such licenses and/or rights.
978-1-492-05122-0
[FILL IN]
Preface
Install the latest Python 3
What you do here depends on the platform you’re running, which is
assumed to be one of Windows, macOS, or Linux.
The good news is that all three platforms run that latest Python, release
3.10. There’s no bad news.
If you are already running release 3.10 or later, move to the next page –
you’re ready. If you haven’t already installed Python or are using an older
version, select the paragraph below which applies to you, and read on.
Installing on Windows
The wonderful Python folk at Microsoft work hard to ensure the most-
recent release of Python is always available to you via the Windows Store
application. Open the Store, search for “Python”, select the most-recent
version, then click the Get button. Watch patiently while the progress
indicator moves from zero to 100% then, once the install completes, move
to the next page – you’re ready.
Installing on macOS
The latest Macs ship with older, out-of-date releases of Python. Don’t use
these. Instead, head over to Python’s home on the web,
https://www.python.org/, then click on the “Downloads” option. The latest
release of Python 3 should being to download, as the Python site is smart