Full Download Ultimate Python Programming 1st Edition Deepali Srivastava PDF DOCX
Full Download Ultimate Python Programming 1st Edition Deepali Srivastava PDF DOCX
com
https://ebookgate.com/product/ultimate-python-
programming-1st-edition-deepali-srivastava/
OR CLICK HERE
DOWLOAD NOW
https://ebookgate.com/product/expert-python-programming-2nd-edition-
jaworski/
ebookgate.com
https://ebookgate.com/product/python-programming-4th-edition-singh-a/
ebookgate.com
https://ebookgate.com/product/black-hat-python-python-programming-for-
hackers-and-pentesters-1st-edition-seitz/
ebookgate.com
https://ebookgate.com/product/practical-maya-programming-with-
python-1st-edition-galanakis/
ebookgate.com
Core Python Programming 2nd Edition Wesley Chun
https://ebookgate.com/product/core-python-programming-2nd-edition-
wesley-chun/
ebookgate.com
https://ebookgate.com/product/programming-python-3rd-ed-edition-mark-
lutz/
ebookgate.com
https://ebookgate.com/product/learning-beaglebone-python-programming-
unleash-the-potential-of-beaglebone-using-python-1st-edition-hiam/
ebookgate.com
https://ebookgate.com/product/advanced-computer-programming-in-
python-1st-edition-karim-pichara/
ebookgate.com
https://ebookgate.com/product/python-programming-for-teens-1st-
edition-kenneth-a-lambert/
ebookgate.com
Cover
Ultimate
Python
ProgrammingLearn Python with 650+
programs, 900+ practice
questions, and 5 projects
Deepali Srivastava
logo
www.bpbonline.com
First Edition 2024
ISBN: 978-93-55516-558
The information contained in this book is true to correct and the best of
author’s and publisher’s knowledge. The author has made every effort to
ensure the accuracy of these publications, but publisher cannot be held
responsible for any loss or damage arising from any information in this
book.
www.bpbonline.com
Dedicated to
I am grateful to the BPB publication team for their guidance and support
provided during every step of the publishing journey. Special appreciation
goes to the editing team, layout team, and all other contributors involved in
bringing this book to life.
Preface
Python is a widely used general-purpose programming language. Its
popularity can be attributed to its simplicity and a rich set of powerful
features. The clean and intuitive syntax makes it an excellent choice for
novices, allowing them to grasp the fundamentals of programming quickly,
and the advanced features make it appealing to experienced programmers
too. It can run on various platforms, including Windows, macOS, and
Linux. Since it is an open-source software, it is freely available to all.
Python is easy to learn. You can start writing Python programs within a few
days. However, if you wish to leverage all the powerful features of Python,
a more in-depth exploration is required. The content in this book can assist
you in achieving that. This book includes 21 chapters that gradually
introduce new topics so learners can proceed at a sustainable pace. If you
are a beginner, start from the first chapter and go through all the chapters in
order, and work out the examples and exercises along the way. If you have
a working knowledge of Python, you can quickly browse through the initial
chapters and then randomly jump to topics that are new to you or that you
want to master. However, I would still recommend reading the chapters in
sequence to get the most out of the book. If you are transitioning from
some other language, you might be tempted to skip the initial information,
but I would suggest you go through all the basic details to avoid any
confusion later. Here is a brief summary of the chapters presented in the
book.
At the end of each chapter, you will find exercises, and their solutions are
provided at the end of the book. I would suggest that you try to solve these
exercises by yourself before looking at the solution. Solving exercises and
writing code will help you to internalize the concepts presented in the book.
By the end of this book, you will develop a strong foundation in core
Python skills and will get the ability to explore the vast range of
functionalities offered by the standard library and third-party libraries. As
you progress, you will continue to be amazed by the capabilities of Python
and the remarkable libraries available. With your newfound skills you can
venture into diverse fields like data science or machine learning. Moreover,
if this is the first programming language you are learning, equipped with
the foundation of programming concepts and problem-solving skills, you
can easily learn any other programming language.
After using this book as a tutorial to learn the language, you can always
refer to it as a handy resource whenever you need to recall or review any
concept and apply it to your work.
Happy programming!
Code Bundle and Coloured Images
Please follow the link to download the
https://rebrand.ly/z815rfg
We have code bundles from our rich catalogue of books and videos
available at https://github.com/bpbpublications. Check them out!
Errata
We take immense pride in our work at BPB Publications and follow best
practices to ensure the accuracy of our content to provide with an indulging
reading experience to our subscribers. Our readers are our mirrors, and we
use their inputs to reflect and improve upon human errors, if any, that may
have occurred during the publishing processes involved. To let us maintain
the quality and help us reach out to any readers who might be having
difficulties due to any unforeseen errors, please write to us at :
Your support, suggestions and feedbacks are highly appreciated by the BPB
Publications’ Family.
Did you know that BPB offers eBook versions of every book published,
with PDF and ePub files available? You can upgrade to the eBook version
at www.bpbonline.com and as a print book customer, you are entitled to a
discount on the eBook copy. Get in touch with us at :
Piracy
If you come across any illegal copies of our works in any form on the
internet, we would be grateful if you would provide us with the location
address or website name. Please contact us at [email protected]
with a link to the material.
If there is a topic that you have expertise in, and you are interested in either
writing or contributing to a book, please visit www.bpbonline.com. We
have worked with thousands of developers and tech professionals, just like
you, to help them share their insights with the global tech community. You
can make a general application, apply for a specific hot topic that we are
recruiting an author for, or submit your own idea.
Reviews
Please leave a review. Once you have read and used this book, why not
leave a review on the site that you purchased it from? Potential readers can
then see and use your unbiased opinion to make purchase decisions. We at
BPB can understand what you think about our products, and our authors
can see your feedback on their book. Thank you!
Join the book’s Discord Workspace for Latest updates, Offers, Tech
happenings around the world, New Release and Sessions with the Authors:
https://discord.bpbonline.com
Table of Contents
1. 1. Introduction to Python
6. 1.6 IDLE
2. 2. Getting Started
1. 2.1 Identifiers
3. 2.3 Objects
8. 2.8 Operators
26. Exercise
3. 3. Strings
1. 3.1 Indexing
20. 3.20 String formatting using the format() method of string class
22. Exercise
18. 4.18 Using a list with functions from the random module
30. Exercise
1. 5.1 Dictionaries
6. 5.6 Getting all keys, all values, and all key-value pairs
22. Exercise
6. 6. Conditional Execution
1. 6.1 if statement
5. 6.5 Truthiness
9. Exercise
7. 7. Loops
9. Exercise
8. 8. Looping Techniques
12. Exercise
9. 9. Comprehensions
13. Exercise
25. Exercise
1. 11.1 Modules
20. Exercise
1. 12.1 Namespaces
3. 12.3 Scope
3. 13.3 Buffering
8. 14.8 Initializer
18. Exercise
11. Exercise
2. 16.2 Adding new methods and data members to the derived class
13. Exercise
1. 17.1 Iterables
2. 17.2 Iterators
14. Exercise
24. Exercise
16. Exercise
18. Exercise
11. Exercise
22. Solutions
23. Index
Introduction to Python 1
Click Yes if it asks for permission to make changes to your device. The
installation begins, and all the required Python files, along with the standard
library, will be installed on your system.
Figure 1.4: Installation in progress
After the installation is complete, the following pop-up box will appear. This
shows that Python is installed on your system. Click on Close to complete
the installation and exit the installer. The appearance of the images shown in
the screenshots may vary depending on the version of Python that you
choose to install.
Figure 1.5: Installation successful
To verify the installation, write cmd in the Start search menu to open the
command prompt window and type the command python --version.
If Python has been successfully installed on your system, it will show the
version of the Python installed. Now write python (all in lowercase) in the
command window. You will see a line with some text describing the Python
version, and after that, you will see a prompt with three greater-than signs
(>>>). This is the Python shell prompt. Write 8 + 2 and press Enter; you
will get the output as 10 on the next line. The prompt appears again; this
time, write print('Hello world'), and the text Hello world will
appear on the next line. This verifies that Python is up and working on your
system. On this interactive Python shell, you can execute single statements
of Python. To quit this Python shell and come back to your command
prompt, type quit() or exit() or press Ctrl-Z.
Figure 1.6: Verifying installation on the command line
You can also verify your installation by opening the Integrated Development
and Learning Environment application(IDLE), which is installed by default
with Python. To open IDLE, type idle or python in the Start search menu
and click on the IDLE app. If the installation is successful, IDLE will show
an interactive Python shell window in which you can type Python commands
at the shell prompt (>>>) and execute them.
1.6 IDLE
To write programs effectively, you need to have a good understanding of the
programming environment. Therefore, it is worth spending some time
looking at the features of IDLE, the IDE that you will be using to write your
programs. If you choose to use a different programming environment, make
sure that you familiarize yourself with it before starting to write programs.
Another Random Scribd Document
with Unrelated Content
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:
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.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
ebookgate.com