Download Complete The Quick Python Book 4th Edition MEAP V01 Naomi Ceder PDF for All Chapters
Download Complete The Quick Python Book 4th Edition MEAP V01 Naomi Ceder PDF for All Chapters
com
https://ebookname.com/product/the-quick-python-book-4th-
edition-meap-v01-naomi-ceder/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/let-s-talk-python-meap-v02-pavel-anni/
ebookname.com
https://ebookname.com/product/programming-python-4th-edition-mark-
lutz/
ebookname.com
https://ebookname.com/product/learning-python-4th-edition-mark-lutz/
ebookname.com
https://ebookname.com/product/to-embroider-the-ground-with-prayer-1st-
edition-teresa-j-scollon/
ebookname.com
Lang Sentence Skls G6 Warrihndbk 2008 Warriner E
https://ebookname.com/product/lang-sentence-
skls-g6-warrihndbk-2008-warriner-e/
ebookname.com
https://ebookname.com/product/the-samurai-invasion-of-
korea-1592-98-stephen-turnbull/
ebookname.com
https://ebookname.com/product/complete-solution-manual-for-single-
variable-calculus-6th-edition-james-stewart/
ebookname.com
https://ebookname.com/product/the-bronze-horseman-paullina-simons/
ebookname.com
Green Building with Concrete Sustainable Design and
Construction 1st Edition Gajanan M. Sabnis
https://ebookname.com/product/green-building-with-concrete-
sustainable-design-and-construction-1st-edition-gajanan-m-sabnis/
ebookname.com
The Quick Python Book, Fourth Edition
1. welcome
2. 1_About_Python
3. 2_Getting_started
4. 3_The_Quick_Python_overview
5. 4_The_absolute_basics
6. 5_Lists,_tuples,_and_sets
7. 6_Strings
8. 7_Dictionaries
9. 8_Control_flow
welcome
Thank you for purchasing the MEAP for The Quick Python Book, 4th edition.
To get the most benefit from this book, you’ll want to have some established
skills in programming, either in Python or in another programming language
like Java, C++, Ruby, Javascript, or something similar. Since this book
assumes an understanding of common data types and flow control structures,
experience with only HTML or SQL may not be a good fit.
The first edition of this book was written over 25 years ago, so it has stood
the test of time. Over that time Python has evolved enormously from the
version 1.5 of the first edition. When I took over as author of the 2nd edition,
covering Python 3.1, I was stunned at how many details had changed, even
while the overall feel of Python had stayed the same. While the changes in
the third edition (for Python 3.6) and this edition (Python 3.13) have been
more manageable, Python has continued to develop, with the addition of new
control structures, libraries, and more.
Finally, the way one uses Python has evolved, and one of the most popular
environments for using Python has become the Jupyter notebook, which
combines text and code in a browser based interface, which makes using
Python much easier, particularly for data exploration. Since Jupyter can be
served via the web, various services can support it, and for this edition we
have shared the the source code (with a couple of exceptions) as Jupyter
notebooks hosted in a Github repository. Those notebooks can be opened in
Colaboratory, Google’s Jupyter based service, with a single click from the
file in the repository. Of course one can still use the tried and true Python
shell as well as sophisticated new IDE’s like Visual Studio Code.
All of this means that while Python has been around over 30 years, and The
Quick Python Book for 25, in this edition we have combined the experience
and feedback from past editions with the latest features of Python and current
tools and presentation.
Finally, to both new readers and old friends of The Quick Python Book, thank
you so much for checking out this MEAP edition.
—Naomi Ceder
In this book
After introducing Python and offering some advice on getting started with a
Python environment, there is a quick summary of Python’s syntax, followed
by chapters that build from the built-in data types up through creating
functions, classes, and packages, as well as some more advanced features and
a case study in handling data.
With the rise of AI tools based on Large Language Models (LLM’s) it is now
possible to generate increasing amounts of usable code if (and it’s a big “if”)
one has enough knowledge of coding to guide the process intelligently. While
this book is not a tutorial on AI and its use in code generation, in the coding
problems posed at the end of each chapter starting with chapter 5, there will
also be examples of AI responses to the same questions along with a brief
discussion of what the AI got right (and wrong). This will help build an
understanding of how to approach using AI tools to generate code that
actually works.
Read the rest of this chapter if you want to know how Python compares to
other languages and its place in the grand scheme of things. If you are
interested in the AI tools this book refers to, check out the end of chapter 2
for a bit about those. Skip ahead—go straight to chapter 3—if you already
have Python installed and want to start learning Python right away. The
information in this chapter is a valid part of this book—but it’s not absolutely
necessary for programming with Python.
Python continues to attract new users for a variety of reasons. It’s a true
cross-platform language, running equally well on Windows, Linux/UNIX,
and Macintosh platforms, as well as others, ranging from supercomputers to
cell phones. It can be used to develop small applications and rapid
prototypes, but it scales well to permit development of large programs. It
comes with a powerful and easy-to-use graphical user interface (GUI) toolkit,
web programming libraries, and more. Python has also become a vital tool
for scientific computing and for data science, machine learning, and work
with artificial intelligence. And it’s free.
Python is well suited for rapid application development. It isn’t unusual for
coding an application in Python to take one-fifth the time it would in C or
Java and to take as little as one-fifth the number of lines of the equivalent C
program. This depends on the particular application, of course; for a
numerical algorithm performing mostly integer arithmetic in for loops, there
would be much less of a productivity gain. For the average application, the
productivity gain can be significant.
The variable temp is needed to save the value of var1 when var2 is put into
it, and then that saved value is put into var2. The process isn’t terribly
complex, but reading those three lines and understanding that a swap has
taken place takes a certain amount of overhead, even for experienced coders.
By contrast, Python lets you make the same swap in one line and in a way
that makes it obvious that a swap of values has occurred:
var2, var1 = var1, var2
Of course, this is a very simple example, but you find the same advantages
throughout the language.
# Python version.
def pairwise_sum(list1, list2):
result = []
for i in range(len(list1)):
result.append(list1[i] + list2[i])
return result
Both pieces of code do the same thing, but the Python code wins in terms of
readability. (There are other ways to do this in Perl, of course, some of which
are much more concise—but in my opinion harder to read—than the one
shown.)
For example, with Python, you can write a web server to share the files in a
directory with just two lines of code:
import http.server
http.server.test(HandlerClass=http.server.SimpleHTTPRequestHandler)
There’s no need to install libraries to handle network connections and HTTP;
it’s already in Python, right out of the box.
Python is also free. Python was originally, and continues to be, developed
under the open-source model, and it’s freely available. You can download
and install practically any version of Python and use it to develop software
for commercial or personal applications, and you don’t need to pay a dime.
Although attitudes are changing, some people are still leery of free software
because of concerns about a lack of support, fearing that they lack the clout
of paying customers. But Python is used by many established companies as a
key part of their business; Google, Rackspace, Industrial Light & Magic, and
Honeywell are just a few examples. These companies and many others know
Python for what it is: a very stable, reliable, and well-supported product with
an active and knowledgeable user community. You’ll get an answer to even
the most difficult Python question more quickly in various Python internet
forums than you will on most tech-support phone lines, and the Python
answer will be free and correct.
Not only is Python free of cost, but also, its source code is freely available,
and you’re free to modify, improve, and extend it if you want. Because the
source code is freely available, you have the ability to go in yourself and
change it (or to hire someone to go in and do so for you). You rarely have
this option at any reasonable cost with proprietary software.
If this is your first foray into the world of open-source software, you should
understand that you’re not only free to use and modify Python, but also able
(and encouraged) to contribute to it and improve it. Depending on your
circumstances, interests, and skills, those contributions might be financial, as
in a donation to the Python Software Foundation (PSF), or they may involve
participating in one of the special interest groups (SIGs), testing and giving
feedback on releases of the Python core or one of the auxiliary modules, or
contributing some of what you or your company develops back to the
community. The level of contribution (if any) is, of course, up to you; but if
you’re able to give back, definitely consider doing so. Something of
significant value is being created here, and you have an opportunity to add to
it.
Python has a lot going for it: expressiveness, readability, rich included
libraries, and cross-platform capabilities. Also, it’s open source. What’s the
catch?
Python’s core developers are also hard at work in creating new versions of
Python that are more efficient, load and run faster, and take better advantage
of multiple processor cores. This work has already yielded significant
improvements in performance, and the work will continue in the future, so if
you have a performance critical application, you may want to consider
carefully if Python will do the job, but you don’t need to write it off
immediately.
'2' #A
x = int(x)
x
2 #B
The fact that Python associates types with objects and not with variables
means that the interpreter doesn’t help you catch variable type mismatches. If
you intend a variable count to hold an integer, Python won’t complain if you
assign the string "two" to it. Traditional coders count this as a disadvantage,
because you lose an additional free check on your code.
In response to this concern Python has added syntax and tools to allow coders
to specify the desired type of the object a variable refers to, as well as
function parameters and return values and the like. With these type hints, as
they are called, various tools can flag any inconsistencies in the types of
objects before runtime. In smaller programs type errors\ usually aren’t hard to
find and fix even without type hints, and in any case Python’s testing features
makes avoiding type errors manageable. Many Python programmers feel that
the flexibility of dynamic typing more than outweighs any advantage
mandatory variable typing might offer.
1.4 Summary
Python is a modern, high-level language with dynamic typing and
simple, consistent syntax and semantics.
Python is multiplatform, highly modular, and suited for both rapid
development and large-scale programming.
It’s reasonably fast and can be easily extended with C or C++ modules
for higher speeds.
Python has built-in advanced features such as persistent object storage,
advanced hash tables, expandable class syntax, and universal
comparison functions.
Python includes a wide range of libraries such as numeric processing,
image manipulation, user interfaces, and web scripting.
It’s supported by a dynamic Python community.
2 Getting started
This chapter covers
Available Python options
Getting started with Colaboratory
Accessing the Github repository for this book
Writing a simple program and handling errors
Using the help() and dir() functions
AI tools for generating Python code
This chapter gives you a quick survey of the many options for installing and
using Python and guides you through getting up and running with Google
Colaboratory, a web hosted Python environment. Combined with the code for
each chapter, available in a Github repository at
https://github.com/nceder/qpb4e, Colaboratory is one of the quickest and
easiest ways to get up and running with Python so that you can test out the
code examples in the text and work through the labs and exercises throughout
the book.
The current release schedule for Python means that after the October, 2024
release of version 3.13, version 3.14 will come out in October, 2025, and so
on. At this writing, Python 3.12 is the most current version, and 3.13 is being
readied for release in a few months. Since the features of 3.13 have already
been frozen, we have included the new features of 3.13 and we have tested
the code on both 3.12 and the beta of 3.13.
Having a new version of Python come out every year is a good thing for
releasing new features, but it’s not always the most convenient thing for
anyone who needs to test and deploy a new version of the language. Because
of this, versions of Python are officially supported for a total of 5 years - the
first 2 years with full releases, and then 3 years with source code only
releases of security fixes.
While it’s usually preferable to have the latest version, any supported version
(3.9 or later as of this writing) should be fine to use with this book. If you
have an earlier version, there will be a few new features that you won’t have,
but you can still do a lot of work without upgrading.
Another option for using and writing Python combines features of the ipython
shell with a web interface and is called Jupyter. Jupyter runs on a server and
is accessed via browser, and its web interface allows you combine text
(formatted using Markdown) with cells for executing code in a “notebook.”
The combination has proved to be so useful that Jupyter notebooks are
increasingly popular for teaching, data exploration and data science, AI
experimentation, and many other uses. While you can run your own Jupyter
server locally, it’s even more convenient to use a server hosted in the cloud,
which brings us to our recommendation for this book.
Another advantage of Colaboratory is that you can launch a session with one
of the code notebooks from this book’s source repository on Github with a
single click, and you can access it on virtually any device that has a modern
web browser.
For that reason, in this book we’ll present sample code and problem solutions
in Jupyter notebooks. Of course, the code will still work in other
environments, and we’ll provide text files of the code as well, but unless
stated otherwise, you can assume that the code presented is in notebook form.
If you click that link it will open that notebook in a Colaboratory session
where you can edit, run, and experiment with the code.
As with Github, you don’t need a Google account to access Colaboratory, but
to run code and use all of the features, including the ability to save sessions
and files, logging in with a Google account is required.
You can also access Colaboratory directly by using your browser to open
https://colab.research.google.com/. This will open Colaboratory with a
“Welcome to Colaboratory” notebook that explains some of the platform’s
features. If you are unfamiliar with Jupyter notebooks, there are some links at
the bottom of this notebook to other notebooks that explain how
Colaboratory’s version of Jupyter notebooks work. If you find yourself a bit
confused at first, those resources can help.
The code cells are for code that can be executed and are always in edit mode.
To execute the code, you can either use Control-Enter or you can right click
on the cell and click on “Run the focused cell.” You can also click on the
little triangle in a circle that appears to the left of the cell when you hover
your mouse over the cell. If there is any output from the execution of the
code, it will appear in the area immediately below the cell. We’ll see how all
of this works as we run our first bit of code below.
Hello, World #B
Here, the code for the print() function, along with the string "Hello, world"
as its parameter, has already been entered into the first code cell of the
chapter 2 notebook. To run it, as mentioned above, you can use Control-
Enter, and the output, “Hello, World” will be printed below the cell. If you
are new to Jupyter notebooks (or to Python), feel free to experiment a bit with
the print function or other commands in this code cell.
Note that throughout this book, we will show the code that is entered into a
code cell in Jupyter (or a Python shell prompt in some other environment)
using a normal weight monospace font, and the output as a monospace bold
font. For comparison, the code and output above should look something like
this in Colaboratory.
Errors are something all coders have to deal with, in virtually every piece of
code we write. If there is an error while running code in a code cell, Jupyter
prints Python’s error message below the cell where the output would go.
Code error messages have been famously difficult to understand, but the
latest versions of Python have improved the clarity and usefulness of error
messages.
# this cell will raise a syntax error
print("Hello, World!" #A
In this case, the code deliberately has a syntax error - the closing parenthesis
has been omitted. Python reports the message and the line where it occurs,
then puts a caret (^) under the error’s location in the line, and finally names
the problem, “incomplete input”.
A nice feature of Colaboratory is that below the Python error message it may
offer an option to attempt to fix the error automatically, with a “Next steps:”
section and a “Fix error” button. In this case clicking on the “Fix error”
button will enter the fix in the code cell above, and allow the user to either
accept or reject it.
— Niin minäkin.
— Ja minä myös.
IV.
‒ Agent-provecateur!
— Enkö minä, enkö minä juuri äsken julistanut, että nuoren polven
innostus on yhtä puhdasta ja valoisaa kuin ennenkin, ja että jos se
joutuu perikatoon, niin tapahtuu tämä vain siksi, että se on
erehtynyt kauniin muodoista! Eikö se vielä riitä! Ja jos tähän lisätään
vielä, että näin on julistanut murtunut ja loukattu isä, niin eikö
todellakaan, — voi teitä, te lyhytjärkiset ihmiset, — niin eikö
todellakaan ole mahdollista aivan puolueettomasti ja rauhallisesti
suhtautua tähän… Te kiittämättömät… epäoikeudenmukaiset… miksi,
miksi te ette halua sopia!…
Juhlan loppu.
I.
II.
Ruhtinas oli ollut alussa tanssiaisia vastaan (t.s. sitä vastaan, että
Julija Mihailovna olisi tullut niihin, vaikka tanssiaiset joka
tapauksessa oli pidettävä), mutta kun hänen mielipiteeseensä täten
oli pari, kolme kertaa vedottu, niin hän oli vähitellen alkanut
ynähdellä myöntyväisesti.
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.
ebookname.com