The Absolute Beginner's Guide To Python Programming: A Step-by-Step Guide With Examples and Lab Exercises 1st Edition Kevin Wilson
The Absolute Beginner's Guide To Python Programming: A Step-by-Step Guide With Examples and Lab Exercises 1st Edition Kevin Wilson
com
OR CLICK BUTTON
DOWLOAD NOW
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://ebookmeta.com/product/the-absolute-beginners-guide-to-
html-and-css-a-step-by-step-guide-with-examples-and-lab-
exercises-1st-edition-kevin-wilson/
https://ebookmeta.com/product/the-absolute-beginners-guide-to-
python-programming-incomplete-1st-edition-kevin-wilson/
https://ebookmeta.com/product/python-games-from-zero-to-
proficiency-beginner-a-step-by-step-guide-to-coding-your-first-
game-with-python-1st-edition-patrick-felicia/
https://ebookmeta.com/product/using-publisher-2019-the-step-by-
step-guide-to-using-microsoft-publisher-2019-1st-edition-kevin-
wilson/
Learn to Program with Python 3: A Step-by-Step Guide to
Programming - 2nd ed 2nd Edition Irv Kalb
https://ebookmeta.com/product/learn-to-program-with-
python-3-a-step-by-step-guide-to-programming-2nd-ed-2nd-edition-
irv-kalb/
https://ebookmeta.com/product/java-a-step-by-step-guide-for-
absolute-beginners-1st-edition-daniel-bell/
https://ebookmeta.com/product/lua-programming-the-ultimate-
beginner-s-guide-to-learn-lua-step-by-step-claudia-alves-
alexander-aronowitz-alves/
https://ebookmeta.com/product/swift-programming-the-ultimate-
beginner-s-guide-to-learn-swift-programming-step-by-step-3nd-
edition-alexander-aronowitz-nln-lnc-aronowitz/
https://ebookmeta.com/product/mastering-the-nikon-zf-mirrorless-
camera-a-beginner-step-by-step-guide-isaiah-wealth/
The Absolute
Beginner’s
Guide to Python
Programming
A Step-by-Step Guide with Examples
and Lab Exercises
—
Kevin Wilson
The Absolute
Beginner’s Guide to
Python Programming
A Step-by-Step Guide
with Examples and Lab
Exercises
Kevin Wilson
The Absolute Beginner’s Guide to Python Programming: A Step-by-Step
Guide with Examples and Lab Exercises
Kevin Wilson
London, UK
Introduction����������������������������������������������������������������������������������������xv
iii
Table of Contents
Output������������������������������������������������������������������������������������������������������������21
Escape Characters�����������������������������������������������������������������������������������������21
Writing a Program�����������������������������������������������������������������������������������������������22
Lab Exercises������������������������������������������������������������������������������������������������������29
Summary������������������������������������������������������������������������������������������������������������30
iv
Table of Contents
Bitwise Operators�����������������������������������������������������������������������������������������������45
Lab Exercises������������������������������������������������������������������������������������������������������45
Summary������������������������������������������������������������������������������������������������������������46
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Shapes��������������������������������������������������������������������������������������������������������������155
Basic Animation������������������������������������������������������������������������������������������������156
Summary����������������������������������������������������������������������������������������������������������164
viii
Table of Contents
F or Loop������������������������������������������������������������������������������������������������������������187
L oop Control������������������������������������������������������������������������������������������������������187
M
odules������������������������������������������������������������������������������������������������������������187
B
uilt-In Functions����������������������������������������������������������������������������������������������187
D
eclare a Class�������������������������������������������������������������������������������������������������188
C
hild Class��������������������������������������������������������������������������������������������������������188
C
reate Object����������������������������������������������������������������������������������������������������188
C
all Object Method��������������������������������������������������������������������������������������������188
A
ccess Object Attributes�����������������������������������������������������������������������������������188
E xceptions���������������������������������������������������������������������������������������������������������188
Index�������������������������������������������������������������������������������������������������189
ix
About the Author
With over 20 years’ experience in the computer industry, Kevin Wilson
has made a career out of technology and showing others how to use it.
After earning a master’s degree in computer science, software engineering,
and multimedia systems, Kevin has held various positions in the IT
industry including graphic and web design, digital film and photography,
programming and software engineering, developing and managing
corporate networks, building computer systems, and IT support. He
currently teaches computer science at college and works as an IT trainer in
England while researching for his Ph.D.
xi
About the Technical Reviewer
Joos Korstanje is a data scientist, with over
five years of industry experience in developing
machine-learning tools. He has a double M.Sc.
in applied data science and environmental
science and has extensive experience working
with geodata use cases. He currently works at
Disneyland Paris, where he develops machine
learning for a variety of tools. His project
experience includes forecasting, recommender
engines, optimization, machine learning on
GPS tracking data, and more. Joos is also an active blogger on Medium and
has worked on multiple book publications.
xiii
Introduction
The aim of this book is to provide a first course in the use of Python to
develop programs.
It provides a foundation for those who wish to write computer
programs based on sound programming principles, and because the book
is intended to be a primer, it allows the beginner to become comfortable
with basic programming tasks.
As it is a first course, no previous experience of computer
programming is assumed.
Throughout the book, we’ll explore the Python programming language
with worked examples and lab exercises for you to complete yourself.
For this purpose, we’ve included all the source code for this book in the
following repository: github.com/apress/absolute-beginners-guide-python
xv
CHAPTER 1
Introduction to
Computer
Programming
What is a computer program? A computer is a device that processes
instructions to achieve a task. This set of instructions is called a computer
program.
A computer program usually takes some data such as a string or a
number and performs calculations to produce results. We usually refer to
the data as the program’s input and the results as the program’s output.
To write computer programs, we use a computer programming
language. There are many different languages such as BASIC, C, C++,
and Python. In this guide, we are going to concentrate on the Python
programming language.
Every computer program manipulates data to produce a result, so
most languages allow the programmer to choose names for each item of
data. These items are called variables or constants. A variable, as the name
suggests, is an item that can contain different values as the program is
executed. A constant stays the same.
What Is Python
Python is a high-level language developed by Guido van Rossum in the
late 1980s and is used in web development, scientific applications, gaming,
AI, and is well suited to education for teaching computer programming.
Python is designed to be an easily readable language. Therefore, it uses
an uncluttered formatting style and often uses English keywords where
other languages use a symbol.
Python is an interpreted programming language, meaning Python
programs are written in a text editor and then put through a Python
interpreter to be executed.
Python is used in the field of artificial intelligence and can be found
in many day-to-day applications. Streaming services such as Spotify use
Python for data analysis, particularly users’ listening habits in order to
offer suggestions on which artist to follow, other music a particular user
might be interested in, and so on. Python is also used within Netflix’s
machine-learning algorithms for recommending relevant content to users,
monitoring browsing habits, and marketing.
2
Another random document with
no related content on Scribd:
Aina on koirain kotona,
Aina pentuin pesässä.
Sitä en tiiä kusta siinnee,
Kusta synty syöpäläisen;
Sienneekö sillan alta
Tulleeko tupa-rikasta
Vaanko vanhoista sioista
Vaanko vattu-raunioista.
Kirppu on kiivas juoksemahan
Sekä hyvä hyppimähän,
Kuka kirpun kiinni saapi
Jalat alta ampukohon
Linnun lyököhön lihaksi
Pankohon pataluhaksi:
Osan kukin ottakohon,
Sääski veren särpäköhön
Kissalle liha-kipene
Koira luut korjatkohon!
Muurahinen ja Kärvänen.
Satu.
Kerran muuan Muurahinen
Sekä kärvänen keviä
Rikeneltä riistelivät
Kahen kesken kamppaelit
Kumpi heistä kuulusampi
Oli onnesta parempi.
Muurahinen muutamilla
Saatti vastata sanoilla:
"Sekä kirkossa kivasti
Että liion linnassakin
Sua varsin vainotahan
Vihatahan viekkahasti.
Kyllä sanot sakeasti
Kerskajat kelpo hyvästi
Että kuljet kunningasten,
Laskeut pää laelle,
Suuta kanssa sukkelasti
Antelet akka väelle;
Mutta koska koreasti
Kesä-kauen kempimällä
Minä ehdin elatusta
Valmistan talven varoja,
Sinun siivota peräti
Näen syöväs synkiästi
Talkkunat nurkan takana
Niiden päällä pärisevän.
Ettei työtä ensinkänä
Sulla ole otollista,
Niin olet typi tyheä
Kanssa kaikesta kalusta:
Eipä maaten markat tule
Istuin iku-hopeat.
Siitä pulskasti puhelet
Kelvoksesti kerskaelet,
Jota joutasit hävyllä
Vaiketa varsin väleen.
Kyllä kerkiät kesällä
Puhumahan pulkiasti,
Mutta talven tarjottua
Vilun ollesa vikevän
Suljet suusi surkiasti
Tukit turpposi äkisti,
Koska jou'ut kohmelohon
Tyhmä tyrmistyt viluhun,
Silloin minä mielelläni
Ilman vaarata isota
Matelen maan sisähän
Hyvän pesäni perälle,
Ruan äärehen äkeän
Kesällä hyvin kerätyn."
Satu.
Heinä-Sirkka ja Muurainen.
Satu.
Muistutus.
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.