Full Download (Ebook) Python Without Fear by Brian Overland ISBN 9780134687476, 0134687477 PDF DOCX
Full Download (Ebook) Python Without Fear by Brian Overland ISBN 9780134687476, 0134687477 PDF DOCX
com
https://ebooknice.com/product/python-without-fear-7204384
DOWLOAD EBOOK
https://ebooknice.com/product/c-without-fear-a-beginner-s-guide-that-
makes-you-feel-smart-2223516
ebooknice.com
ebooknice.com
https://ebooknice.com/product/supercharged-python-take-your-code-to-
the-next-level-10446384
ebooknice.com
https://ebooknice.com/product/mind-without-fear-46703704
ebooknice.com
(Ebook) Fear No Evil (Alex Cross, #29) by James Patterson
ISBN 9780316499163, 0316499161
https://ebooknice.com/product/fear-no-evil-alex-cross-29-36398310
ebooknice.com
https://ebooknice.com/product/bears-without-fear-5146484
ebooknice.com
ebooknice.com
ebooknice.com
ebooknice.com
Python Without Fear
Brian Overland
Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town
Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City
São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
Acknowledgments xxi
Author Bio xxiii
vii
Index 407
xvii
you might end up writing a program the way a C programmer would. It runs,
but it doesn’t use any of the features that make Python such a fast develop-
ment tool.
a_list = ['Don\'t', 'do', 'this', 'the' ,'C', 'way']
for x in a_list:
print(x, end=' ')
This little snippet prints
Don't do this the C way
Why Python?
Of course, if you’re trying to decide between programming languages, you’ll
want to know why you should be using Python in the first place.
Python is quickly taking over much of the programming world. There are
some things that still require the low-level capabilities of C or C++, but you’ll
find that Python is a rapid application development tool; it multiplies the
effort of the programmer. Often, in a few lines of code, you’ll be able to do
amazing things.
More specifically, a program that might take 100 lines in Python could
potentially take 1,000 or 2,000 lines to write in C. You can use Python as
“proof of concept”: write a Python program in an afternoon to see whether
it fulfills the needs of your project; then after you’re convinced the program is
useful, you can rewrite it in C or C++, if desired, to make more efficient use of
computer resources.
With that in mind, I’ll hope you’ll join me on this fun, exciting, entertaining
journey. And remember this:
x = ['Python', 'is', 'cool']
print(' '.join(x))
Register your copy of Python Without Fear on the InformIT site for con-
venient access to updates and/or corrections as they become available. To
start the registration process, go toinformit.com/register and log in or create
an account. Enter the product ISBN (9780134687476) and click Submit. Look
on the Registered Products tab for an Access Bonus Content link next to
this product, and follow that link to access any available bonus materials.
If you would like to be notified of exclusive offers on new editions and
updates, please check the box to receive email from us.
xxi
xxiii
Van Rossum named the language after the BBC comedy series Monty
Python’s Flying Circus, so the connection to pythons is indirect, although
troupe member John Cleese originally came up with “Python” as suggesting
something “slithering and slimy” (source: Wikipedia.org). So there you have
it—there is a connection to reptiles after all.
Since then, several versions of Python have been developed, adding important
capabilities, the latest of which is Python 3.0. This book uses Python 3.0,
although it includes notes about adapting examples to Python 2.0.
Unlike most languages, Python has no “begin block” or “end block” syntax—
all relationships are based on indentation! Although this might seem risky to a
C programmer, it enforces a consistent look that’s more comprehensible to
beginners.
Python has no variable declarations. You create variables by assigning values
to them. This goes a long way toward simplifying the language syntactically,
but it also creates hidden “gotchas” at a deep level. This book will steer you
around them.
Python is built heavily on the idea of iteration, which means looping through
sequences. This concept is built deeply into high-level structures (lists, dictio-
naries, and sets). Use them well, and you’ll be able to get a great deal done in
a small space.
1
If you later want to improve machine-level efficiency, you can later rewrite the
program in C or C++.
keyword itself is in bold, while the name of the variable—which you supply—
is in italics.
global variable_name
code This icon indicates a block of pseudocode, which systematically describes each
Pseudo
ses This icon indicates a section that provides exercises based on the preced-
Exerci
ing example. You’ll learn Python much faster if you try at least some of the
exercises.
izing
This icon precedes a section that shows how to revise or greatly improve an
Optim
example. These are not included for every example. Where this book does use
them, it’s because the example used the more obvious way to do something;
the “optimized” approach will then show how the more experienced, sophisti-
cated Python programmer would handle the job.
Installing Python
The steps for installing Python are essentially the same regardless of whether
you have a Windows-based system, Macintosh, or any other system that Python
supports. Here are the basic steps:
If all goes well, Python is installed on your computer with all the basic mod-
ules, tkinter (GUI development) included. Now you have a choice to make.
To start using Python, you can use “basic interactive mode”—which is func-
tional but nothing special—or you can use IDLE, the interactive development
environment.
I strongly recommend the latter. IDLE does everything the basic interactive
mode does, and a great deal more. In the next section, I describe some ways of
using IDLE that can save you a lot of time later.
Here’s what basic interactive mode looks like. It offers only rudimentary
editing and no support for loading programs from text files.
*****
"Jos sinä, Pekka Drufva, tahdot kostaa minulle kaiken sen pahan,
minkä tein sinulle Ahvenanmaalla, niin Jumalan tähden, iske minuun
heti, sillä olen jo kärsinyt helvetillisiä tuskia syntieni sovitukseksi sekä
sinua että muita vastaan."
"Sinä taisit pelätä, Lassi, että aioin nyt kostaa sinulle sen, minkä
Ahvenanmaalla teit minulle. Voin vakuuttaa, etten hetkeäkään ole
mitään sellaista ajatellut. Kosto on paha, joka tavallisesti tahraa
kostajaa enemmän kuin hänen uhriaan. Eihän meidän,
lyhytnäköisten ihmisten asia ole kostaa, korkeintaan meidän tulee
rangaista, jos rankaisu tapahtuu oikeuden ja kohtuuden mukaan.
Sen pahan johdosta, jota minulle olet tehnyt, Lassi, olet sinä
mielestäni saanut kylliksi suuren rangaistuksen. Muuten voidaan
panna kysymykseen, tokko oikeastaan olet tehnyt minulle mitään
pahaa. Sinä tartuit minun elämääni ja annoit sille uuden suunnan,
mutta siitä ei minulla ole vähintäkään valittamisen syytä. Jollei sinua
olisi ollut, niin olisin kai minä nälällä ja vaivalla päässyt kappalaiseksi
jonnekin Ruotsissa tai Suomessa. Se olisi varmaankin paljoa
vähemmän miellyttänyt minua kuin nykyinen elämäni, joskaan en
erinäisistä syistä enää ole oikein tyytyväinen siihenkään. Mutta nyt
sinun pitää kertoa minulle, mikä kummallinen kohtalo on tuonut
sinut tänne, niin että aivan odottamatta tapasimme toisemme tässä
erämaassa."
Rapatalon Lassi kertoi nyt seikkailunsa. Pian sen jälkeen kun Pekka
Drufva oli lähtenyt Ahvenanmaalta, oli hän myönyt talonsa ja ottanut
pestin laivaan. Sitten hän oli purjehtinut monella suurella aluksella,
viimeksi englantilaisella, jonka oli määrä mennä Länsi-Intiaan.
Atlantin valtamerellä oli noussut kova myrsky, laiva oli eksynyt
oikeasta suunnastaan ja vihdoin saanut vuodon. Yötä päivää tehtiin
työtä pumppujen ääressä, sillä lännessä häämöitti maata, joka
varmaankin oli Amerikan mannerta, ja toivottiin, että laiva ennättäisi
ajautua maihin ennenkuin se uppoaisi. Mutta se ei onnistunut. Alus
alkoi vajota. Silloin miehistö asettui kahteen pieneen
pelastusveneeseen, kapteeni ja kolme miestä toiseen, ja perämies ja
kolme miestä, joiden parissa Lassikin oli, toiseen. Minne kapteenin
vene joutui, sitä ei Lassi tiennyt, sillä veneet joutuivat jo heti erilleen
toisistaan. Mutta vihdoin perämiehen vene pääsi hiekkarantaan.
Siellä he nousivat maihin. Maa näytti asumattomalta, mutta
samoiltuaan jonkun aikaa sinne tänne, kohtasivat he intiaanikylän,
jossa ei kuitenkaan ollut muita kotosalla kuin pari vanhaa ukkoa sekä
naisia ja lapsia. Heille kerrottiin, että kaikki miehet olivat lähteneet
sotaan toista intiaaniheimoa vastaan, jotka nimittivät itseään
irokeeseiksi. Aluksi oli merimiesten hyvin vaikea tulla toimeen
kylässä, jossa ei kukaan ymmärtänyt englanninkieltä. Mutta
sattumalta Lassi oli tullut puhuneeksi ruotsia eräälle intiaanivaimolle
ja suureksi hämmästyksekseen hän huomasi, että tämä ymmärsi
häntä. Hän sai nyt kuulla, että ruotsalainen linnoitus ja ruotsalaisia
uutisasukkaita oli jonkun matkan päässä sisämaassa ja että
ruotsalaiset olivat mohikaanien hyviä ystäviä, niin, olivatpa he
lähettäneet apujoukkoja sotaankin irokeesejä vastaan. Me jatkamme
nyt Lassin omilla sanoilla:
"Hyvä, sillä nimellä minäkin tahdon kutsua sinua, sillä vanha nimi
repii turhat haavat auki. Nyt saat seurata mukanani ruotsalaisten
siirtokuntaan, missä minä asun, ja minä pidän kyllä huolta siitä, että
haavasi paranevat pian. Sitten saat jäädä sinne tai lähteä jollakin
laivalla merille, aivan niinkuin haluat."
*****
Sillä välin kuin muut tanssivat, astelee Pekka Drufva käsi kädessä
Greta neidon kanssa metsätiellä, joka johtaa Huokausten mäelle.
Heidän välillään ei ollut oikeastaan koskaan ollut puhetta
rakkaudesta, vielä vähemmän Pekka oli kosinut Gretaa sanan
tavallisessa merkityksessä. Mutta he tiesivät rakastavansa toisiaan ja
puhuivat keskenään kieltä, jota vain rakkaus täysin ymmärtää —
kuitenkin enemmän katsein kuin sanoin.
"Juuri siksi, että kerran voisin sen tehdä, minun täytyy lähteä
täältä."
"Kyllä sinä sen heti käsität. Sanohan, pikku Greta, tahtoisitko sinä
mennä naimisiin miehen kanssa, joka ei olisi muuta kuin siirtokunnan
metsästäjä ja tiedustelija?"
"Ei, pikku Greta, se olisi liian suuri harppaus. Täällä on toisia, joilla
on oikeus ennen minua sellaiseen korotukseen. Vänrikki Liljehöökillä
esimerkiksi. Muuten, pikku Greta, en minä kykene sellaiseen
paikkaan, sillä voidakseen komentaa sotilaita, täytyy itsekin olla
sotilas, mutta sitä minä en ole. Eikä Uusi Ruotsi ole sopiva koulukaan
sitä varten. Ei, aivan toisella tavalla minun on voitettava sinut."
Maanmittareista oli siihen aikaan suuri puute, mutta ansio oli hyvä.
Siten aika kului. Luopuipa kuningatar Kristiina vihdoin
valtaistuimestaan ja Kaarle Kustaa tuli kuninkaaksi. Sen mukana
syttyi Puolan sota, ja Pekka Drufva läksi kesällä 1655 taas mukaan.
Samana vuonna everstiluutnantti Printz palasi Ruotsiin, jätettyään
kuvernöörin paikkansa Uudessa Ruotsissa luutnantti Johan
Papegojalle. Mutta vasta syksyllä hän perheineen astui maihin
Göteborgissa, ja silloin oli Pekka Drufva jo Puolassa.
Oikea saapuu.
"Mutta ajattelehan toki, Greta, sinä täytät pian 27 vuotta. Etkö aio
koskaan mennä naimisiin?"
"Sitten minusta kai tulee vanhapiika. En luullut, että sinä, isä kulta,
haluaisit päästä minusta."
"Annahan kuulla."
"Minä epäilen sitä miestä, jonka sinä, isä kulta käskit tiedustella
asiaa. Luutnantti Gyllenspets tiesi, missä suhteessa olen Drufvaan.
Mutta tuotuaan minulle nuo masentavat tiedot, hän kosi minua.
Voihan siis helposti epäillä, etteivät hänen tiedustelunsa olleet
puolueettomia."
"Ahvenanmaan Lassi."
Greta neidon sydän sykähti. Sillä hän oli tuntevinaan sekä nimen
että miehen.
Updated editions will replace the previous one—the old editions will
be renamed.
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.
ebooknice.com