Python For Kids For Dummies - Brendan Scott - E-Book

Python For Kids For Dummies E-Book

Brendan Scott

0,0
22,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The kid-friendly way to learning coding with Python Calling all wanna-be coders! Experts point to Python as one of the best languages to start with when you're learning coding, and Python For Kids For Dummies makes it easier than ever. Packed with approachable, bite-sized projects that won't make you lose your cool, this fun and friendly guide teaches the basics of coding with Python in a language you can understand. In no time, you'll be installing Python tools, creating guessing games, building a geek speak translator, making a trivia game, constructing a Minecraft chat client, and so much more. Whether you don't have the opportunity to take coding classes at school or in camp--or just simply prefer to learn on your own--Python For Kids For Dummies makes getting acquainted with this popular coding language fast and easy. It walks you step-by-step through basic coding projects and provides lots of hands-on tasks that give you a sweet sense of accomplishment when you complete them. What's not to love about that? * Navigate the basics of coding with the Python language * Create your own applications and games * Find help from other Python users * Expand your technology skills with Python If you're a pre-to-early-teen looking to add coding skills to your creativity toolbox, Python For Kids For Dummies is your sure-fire weapon for getting up and running with one of the hottest programming languages around.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 318

Veröffentlichungsjahr: 2015

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Python® For Kids For Dummies®

Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com

Copyright © 2015 by John Wiley & Sons, Inc., Hoboken, New Jersey

Media and software compilation copyright © 2015 by John Wiley & Sons, Inc. All rights reserved.

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Python is a registered trademark of Python Software Foundation. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2015944529

ISBN 978-1-119-09310-7 (pbk); ISBN 978-1-119-11216-7 (ebk); ISBN 978-1-119-11085-9 (ebk)

Python® For Kids For Dummies®

Visit www.dummies.com/cheatsheet/pythonforkids to view this book's cheat sheet.

Table of Contents

Cover

Introduction

About This Book

Conventions Used

Foolish Assumptions

Icons Used in This Book

Beyond the Book

Where to Go from Here

Week 1: Slithering into Python

Project 1: Getting Started with Python

Python and Why It’s Wonderful

Who’s Using Python

Making Things with Python

Understanding This Book’s Pedagogical Approach

Install Python on Mac OSX

Install Python on Windows

Install Python for Linux

Pin Python to Your Start Menu

Start the Python Interpreter

Use Python’s Built-In Documentation

Put the Kibosh on the Python Interpreter

Find Python Documentation Online

Join the Broader Python Community

Handle Problems

Learn How to Learn

Summary

Project 2: Hello World!

Write

Hello World!

Spot and Fix Errors

Work with Literals

Literally Save Your Strings in Variables

Interrupt a Program

Drive Up to Python Keywords

Many Loop, Much Hello

Fill the Screen with Greetings

Make Python Count

Summary

Week 2: Building Guessing Games

Project 3: Guessing Game

Plan the Game

Get Input from the Player

Ask for Input

Make Sure Things Are Equal

Call the Operators

Divide in Python

Compare the Guess to a Number

Compare the Player’s Guess to the Computer’s Number

Tell Players If the Guess Is Wrong

Keep Asking Until the Player Guesses Correctly

Make Python Think of a Random Number

Use Namespaces

Finish Your Guessing Game

Summary

Project 4: Set Up Your Coding Environment

Use the Default Development Environment

Start IDLE

Stash Some IDLE Tricks

Use the IDLE Editor Window

Write Comments in Your Files

Insert Hash Comments

Save Your Shell Contents

Comment Out Code

Indent and Dedent Your Code

Summary

Project 5: A Better Guessing Game

Handle Your Functions

Naming Functions

Add Function Help Text

Make a Function Stub

Rework Your Guessing Game

Find a Logic Problem

Solve the Logic Problem

Notice Double Use of

computers_number

Understand How Scope Works

Communicate with Your Function

Send Information to a Function

Give Some Arguments a Default Value

Communicate from the Function

Add a Score

Let the User Quit

The Complete Code

Summary

Week 3: Creating Word Games

Project 6: Hacker Speaker: 1337 Sp34k3r

Waiter, There’s An Object In My String

Dot Your Objects’ Attributes

Meet the List

Go Through the Elements of a List

Create Your Own List

Create a List on Steroids

Test Whether an Element’s In a List

Planning Your Elite Hacker Speaker

Set Up Your File

Make Code Letter Substitutions

Replace a Letter

Let the User Enter a Message

Define Letter Substitutions

Apply all the Substitutions

Use

print

to Debug the Code

Debug with IDLE’s Debugger

Summary

Project 7: Cryptopy

Slice Off Those Dud Characters

Make a Substitution Table

Set Up Your Cipher

Use the Dictionary

Create an Encryption Dictionary

Use a

join

Rewrite the Encryption Function

Write the Decryption Function

Encrypt a Text File

Encrypt and Decrypt from a File

Decrypt from Your Shell

Change the Code to Decrypt Too

The Complete Code

Summary

Project 8: Silly Sentences

Insert Format Strings

Have the Right Number of Values

Use the Tuple Data Type

Get Started on Your Silly Sentences

Fill the Template

Add More Words

The Complete Code

Summary

Week 4: Stepping Up to Object-Oriented Programming

Project 9: Address Book

Your First Class Objects

Create a Class

Create an Instance

Create Class and Instance Attributes

Plan Your Address Book

Set Up Your File and Create a Class

Add Your First Person

Instantiate an Instance Using

__init__

Create a Function to Print the Instance

Use

__repr__

Magic

Initialize the

AddressBook

Instance

Find Pickle Power

Add a

save

Function

Loading a Saved Pickle in the Same Application

Test the

load

Method

Add an Interface

Fill in the Methods

The Complete Code

Summary

Project 10: Math Trainer

Planning Your Math Trainer

Setting Up

Create Questions

Ask Lots of Questions in a Row

Print Out a Times Table

Print Multiple Tables Across the Screen

Start on the User Interface

Add Quit Functionality

Polishing It Off

Summary

About the Author

Cheat Sheet

Connect with Dummies

End User License Agreement

Guide

Cover

Table of Contents

Begin Reading

Pages

i

ii

iii

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

316

Introduction

Hi! Welcome to the book. You’re going on a tour of all things Python. If you join me and code along with the projects, you’ll have your basic Python programming wings by the end of the book.

Everything in this book you need to know by doing — typing in the code or, better yet, thinking up the code before reading what I’ve done.

About This Book

This book walks you through all the parts you have to know about Python programming. You get examples. I talk about planning programs. And I help link you with the broader Python community so that you can head out there after mastering the projects in this book.

Foolish Assumptions

I’ve tried not to make too many assumptions about you in this book. In order to use this book, you need to be able to turn on your computer and navigate the Start Menu (on Windows). To install Python you will need administrator access for the computer you’re installing it on.

Learning anything is slow going to start. You are going to need a bit of determination to make it through the book. Hang in there.

Icons Used in This Book

The Warning icon tells you to watch out! This information may save you headaches. In some cases, you could lose data if you don’t heed the warnings.

You’re gonna use this information for a long, long time. Commit it to long-term gray matter.

The Tip icon marks shortcuts that make programming easier.

Coding Connections icons mark information that applies not just to Python, but to coding in general.

Beyond the Book

You can find a bunch more information outside this book. Check out:

Cheat Sheet:

This book has an online cheat sheet at

www.dummies.com/cheatsheet/pythonforkids

. The Cheat Sheet has a list of Python keywords, common built-ins, and selected functions from the standard library. Use it as a quick reference when you’re coding.

Dummies.com online articles and bonus projects:

In addition to the projects in this book, there are some bonus projects online. You can get them from

www.dummies.com/extras/pythonforkids

.

python4kids.brendanscott.com

: Visit my Python for Kids blog. Many of the projects in this book started out there. The blog has a dedicated blog entry for each of the projects and has a heap of other things you can try, too. If you’ve got feedback, you can leave it on the blog page that applies.

Where to Go from Here

Right now you should go to Project 1 to read more about what this language can do and to install it. Before you move on to Project 2, make sure you know about Ctrl+C. Then you’re ready to write your first Python program! Move in and out of the projects as you like. The code in each project stands on its own. Be careful though — even though they don’t use code from earlier projects, they often use concepts introduced earlier.

Week 1

Slithering into Python

This week you’re …

Getting Started with Python

Building Hello World!

PROJECT 1

Getting Started with Python

In this project, you’re introduced to Python: where it’s used and what it’s used for. I explain the two current versions of Python. This book is focused on Python 2.7 and I explain why. With my help during this chapter, you install a copy of Python 2.7 (if you don’t already have it installed) and fire it up. I also tell you how to stop once you’ve started.

This project also shows you how to get Python’s documentation, both built in to Python and online. I give you ways to search online for answers to your Python problems, just in case you’ve never searched the Internet before. You also read about the Python community, which is one place you can go for help or new ideas. All that, but no actual programming? No worries. Actual programming starts in Project 2.

TL;DR: If you’ve already installed Python, and you can start and stop it, then skip to Project 2.

Python and Why It’s Wonderful

Python is a programming language written by a person called Guido van Rossum in the 1990s. Programming languages allow you to control what a computer does and the way it does it.

Some of the things that make Python totes awesome (also known as “really helpful and lots of fun”) are:

Python code is easy to read and understand.

In fact, I think Python’s code is sublime and beautiful. (Hey, that’s just my opinion.) Its beauty means you don’t even notice the way Python makes complex things simple. This makes Python easy to learn, which makes it perfect for kids.

Python is productive.

It makes tough tasks simple. Almost any programming task is easier with Python than it is with other programming languages. Computer types call this

RAD

(for Rapid Application Development).

Python is dangerous.

It has a lot of power. But with great power comes great responsibility. (Remember Spider-Man?) And you’ll have to use your powers for good, not evil. (If you want to use them for evil, you have to stop reading now.)

Python is a scripting language.

The programs are fed into Python’s interpreter, which runs them directly, so there’s no compiling (which is the case for some other languages). It is faster and easier to get feedback on your Python code (finding errors, for example). Python means you complete and

execute

(run) your programs faster and that makes programming fun!

Python is cross platform.

Almost anyone can use it, no matter what computer operating system they have. You can run pretty much any Python program on Windows, Mac, and Linux personal computers and from large servers through to tiny computers like the Raspberry Pi. (A Pi-specific project is waiting at

dummies.com/go/pythonforkids

for you.) You can even run Python programs on Android and iOS tablets. I even used my Android tablet to code some of the early projects in this book.

Python uses dynamic typing for its variables.

This may not mean much to you if you’ve never done programming before. Dynamically typed variables make programming easier because they let you just start using a variable, rather than first explaining to the computer what the variable is supposed to be.

Python gets lots of help from

third-party modules

.

This means that a lot of other people (third parties) have written libraries. A

library

is a bunch of code for doing something specific. This makes your work easier because you don’t have to start from scratch every time you write a new program; sometimes you can use the libraries already written. The Minecraft project online uses a third-party library to change a Minecraft game on a Raspberry Pi.

Python is free software.

This means that the license terms for Python respect your freedom. I think this is pretty important. You can download and run Python without paying any money, and any program that you write with it is yours to use and share any way you want. It also means that the Python

source code

(the human-readable form of what the computer runs) is available so, when you’re feeling brave enough, you can look at how the Python developers wrote their code. (It’s written in a different programming language, though, d’oh!)

Pythons aren’t just snakes

The Python programming language is named after a comedy group called Monty Python, not the reptile. Monty Python was active mainly in the 1970s. (40 years ago! Forever and ever, right?) They had a British television show called Monty Python’s Flying Circus and have made lots of movies, the most notable of which is Monty Python and the Holy Grail.

Who’s Using Python

Python is used just about everywhere.

In space:

The International Space Station’s Robonaut 2 robot uses Python for its central command system. Python is planned for use in a European mission to Mars in 2020 to collect soil samples.

In particle physics laboratories:

Python helps understand the data analysis from some atom smashing experiments at the CERN Large Hadron Collider.

In astronomy:

The MeerKat Radio telescope array (the largest radio telescope in the Southern Hemisphere) uses Python for its control and monitoring systems.

In movie studios:

Industrial Light and Magic (

Star Wars

geniuses) uses Python to automate its movie production processes. Side Effects Software’s computer-generated imagery program Houdini uses Python for its programming interface and to script the engine.

In games:

Activision uses Python for building games, testing, and analyzing stuff. They even use Python to find people cheating by boosting each other.

In the music industry:

Spotify music streaming service uses Python to send you music.

In the video industry:

Netflix uses Python to make sure movies play

(stream)

without stopping. Python is used a lot for YouTube.

In Internet search:

Google used Python all over in its early development phase.

In medicine:

The Nodality company uses Python to handle information that they use to search for a cure to cancer.

In your OS (admin-ing your datas):

Operating systems like Linux and Mac OSX use Python for some of their administrative functions.

In your doorbell:

Rupa Dachere and Akkana Peck say that you can automate your home with Python, hooking up sensors to your house. With it you can, for example, open and close the curtains or automatically turn on lights when you come in the room.

I could go on. The point is that Python will apply to whatever you’re interested in, no matter what it is.

Making Things with Python

You do these things while you work through this book:

Make a math trainer for practicing your times tables.

Make a simple

encryption

(a secret code) program.

Use Python on a Raspberry Pi to work with and modify your Minecraft world. (See

www.dummies.com/go/pythonforkids

for that project.)

When you’ve honed your mad skills and are ready to move on, there’ll be other things you can do:

Using

Tkinter

(or other widget sets), you can write user applications that use graphics rather than just text to interact with the user.

You can extend other programs like Blender (a 3D modeling program), GIMP (a 2D photo-retouching program), and LibreOffice (office programs), among many others by writing custom scripts. I had to fix some 3D models I was making in Blender. It would’ve taken forever to do by hand, so I wrote a Python script to do it quickly.

You can write games with graphics using

Tkinter

or the Pygame or Kivy libraries. The games in this book are text only.

You can use the matplotlib library to draw complex graphs for your math or science courses.

Using the openCV library, you can experiment with computer vision. People who are into robotics use it to help their robots see and grab things and to avoid obstacles when moving.

Whatever you want it to do, there’s a good chance someone has already written code to do it or to help you do it yourself.

Understanding This Book’s Pedagogical Approach

That title is just to impress your parents. (I hope they’re not reading this part. But look: If they don’t see that title, tell them that this book has a pedagogical approach — ped-uh-goj-i-cul. It means education or teaching.)

The point of this book is to give you a chunk of information about the programming concepts that you need to program in Python. The book is for you — a kid who can learn Python.

I am thorough

Thorough, yes. Will I include everything? No way. Many aspects of Python have lots of options. If I took you through all the possibilities of each option, you’d fall asleep (or throw this book out the window). If you do either of those things, then you won’t be learning.

As you read, remember that I’ve tried to introduce you to enough information so you can be a Python programmer, but not so much that you’d need superhuman powers to get through it. Expand on your own using the documentation and help.

You start pretty slowly with core (main) principles. If you think things aren’t going fast enough, skip ahead! The examples are generally self contained. This means that you end up with many smaller projects rather than a few larger projects. I did that on purpose so you can do the projects in any order you like. You’ve got enough people telling you what to do. You can go where you want to in this book.

The earlier projects use plain English, rather than technical words. As you go through the book, you’ll see more jargon. You’ll also get less hand holding. You’ll have to work harder the further you get through the book.

If you’re dying to know more

If you really want to know everything about one particular part of Python, first try Python’s help function, its introspection features, and its online documentation. Each of these is introduced later in this project. You can also try some of the reference manuals. They’re different from instructional books (which is what this is). This book: filled with wildly interesting information and humor. Reference manuals: filled with boring (but useful and sometimes important) details. You can also try one of the Python cookbooks (a book with coding recipes that solve specific problems).

I walk you through programming

The projects try to show you realistic programming without boring you to tears. When you write your own code to solve your own problems, you’ll need methods and approaches (tools) that get the job done. I teach you these tools by walking you through each project, step by step. Try every step — don’t skip any.

If you want to run the working program, skip to the end of the project and cut and paste. If you want to learn Python, then consider each project a journey, not a destination. Work through the projects with me and type them in yourself.

I am practical

Hopefully, you can use these projects for something in your everyday life. Maybe they’ll help with your homework or let you store private notes. I start small and dream big. Please dream big with me while you’re getting the concepts in the first projects.

Why this book uses Python 2.7

The Python language is changing from Python 2.7 (sometimes called Python 2) to a new version, called Python 3. This change is taking years to complete. Python 3 is very similar to Python 2, but the two are incompatible — they don’t work together. If you write a script that works in Python 2, it isn’t guaranteed to work in Python 3 (and vice versa).

Deciding whether to use Python 2 or Python 3 in this book was difficult. I focus on Python 2 (specifically Python 2.7) mainly because I think it still has the best third-party libraries. For example, the Minecraft Pi project at www.dummies.com/go/pythonforkids needs Python 2. If you want to do something productive using Python, and you need to use a third-party module to do it, you’ll probably need Python 2. Third-party modules that work with Python 3 often have a version that works with Python 2 support, but the reverse isn’t true. This will change over the next couple of years.

The way Python 3 is different from Python 2 is mainly in advanced features. Because of that, even if I based the book on Python 3, I wouldn’t cover most of what’s new about Python 3.

Finally, Python 2 is part of the standard install on Mac OSX computers, which means that this book should be usable by Mac owners without your having to download and install anything. Most Linux comes with Python installed (but make sure you have Python version 2.7).

Install Python on Mac OSX

To find and start Python on Mac OSX computers, follow these steps:

Press Cmd+spacebar to open Spotlight.

Type the word terminal.

Or, from the Finder, select Finder ⇒ Go ⇒ Utilities ⇒ Terminal.

The Terminal window opens.

In the terminal, type python.

The Python interpreter that’s built in to Mac OSX opens.

Install Python on Windows

Unfortunately, Python doesn’t come on Windows. If you’re running Windows, then you need to download and install Python by following the instructions here. Installing Python on Windows isn’t difficult. If you can download a file from a website, you have the skills to install Python.

Fortunately, the Python Foundation (the peeps who guide the development of Python) makes installable files available from its website.

When I did the installation, I found that Firefox and Internet Explorer responded differently to the Python download website, so the instructions are based on which of these browsers to use. If you use a whole other browser altogether, try the Internet Explorer instructions.

With Firefox

To install Python on a Windows machine with Firefox, follow these steps:

Visit

www.python.org/downloads

.

Click the button that says Download Python 2.7.9.

Or, if it’s there, click a more recent version number that starts with 2.7.

Clicking this button automatically downloads and saves an msi file for you. If not, try the instructions for Internet Explorer. See Figure 1-1.

When the download’s complete, click the icon for Firefox’s download tool.

Click the file called python-2.7.9.msi (or the more recent version, if you downloaded one).

Python 2.7.9 installs on your computer.

Figure 1-1: Download Python with Firefox.

With Internet Explorer

To install Python on a Windows machine with Internet Explorer, follow these steps:

Visit

www.python.org/downloads

.

From the menu bar, select Downloads ⇒ Windows.

You can see the menu options in Figure 1-2.

Scroll down to the heading Python 2.7.9-2014-12-10.

Or scroll to a more recent version, which starts with Python 2.7, if one is available.

Under this heading, click the link titled Download Windows x86 MSI Installer.

See Figure 1-3. This is a link for a 32-bit installation, which makes things work better with third-party libraries. Use the 32-bit installer even if you have a 64-bit machine and even if you have no idea what this paragraph is talking about.

If you’re asked to choose whether to run or save the file, choose Run.

This downloads python2.7.9.msi and starts running the installer.

If you get a security warning when the installer begins (or at random times during the installation), choose Run.

Accept the default installation options that the installer provides.

Figure 1-2: Download Python with Internet Explorer.

Figure 1-3: Python x86 MSI Installer.

Install Python for Linux

If you’re running Linux, confirm that you have version 2.7.9 of Python installed, rather than version 3. This shouldn’t be a problem because Python 2.7 is installed by default in recent versions of OpenSuSE, Ubuntu, and Red Hat Fedora.

In the nutty odd case when someone has Python 3 but not Python 2.7, read your distribution’s documentation for how to use the package manager and get Python 2.7 and IDLE.

Pin Python to Your Start Menu

After you’ve downloaded Python, it’s a good idea to pin it to your Start menu. That way you can find it more easily for the rest of this book.

Type Python in the Start menu’s search bar, or click All Programs. In the folder Python 2.7, you should find the following entries (see Figure 1-4):

IDLE (Python GUI)

Module Docs

Python (command line)

Python Manuals

Uninstall Python

Figure 1-4: Python entries in Start menu.

Of these, you’ll use:

IDLE (Python GUI)

Python (command line)

To make IDLE and the command line easier to find, pin them to your Start menu:

Open your Start menu.

Choose All Programs ⇒ Python 2.7.

Right-click IDLE (Python GUI). See

Figure 1-5

.

Select Pin to Start Menu.

Right-click Python (command line).

Select Pin to Start Menu.

You should see the entries at the top of your Start menu. If you prefer, you can pin them to your taskbar.

Figure 1-5: Right-click to pin Python to your Start menu.

Python on tablets

Are you interested in running or programming Python using your tablet? If you’re interested in writing a program for a tablet, take a look at the Kivy library. I installed SL4A, the Scripting Layer for Android, on my tablet, along with its Python interpreter and drafted some early chapters using SL4A. Check your tablet’s app store for Python interpreters and see whether any fit your ability.

Because different tablets display graphics different ways, Python has to use special libraries to write programs other than plain text. Tablets are only useful for the non-graphical projects in this book — unless you’re prepared to research those libraries and rewrite the projects to use them. In that case, you’re beyond this book.

Also, it’s better to have a hardware keyboard. Soft (onscreen) keyboards usually don’t give easy access to the punctuation that Python needs (or, in my experience, for everyday English — but that’s another matter … ).

Start the Python Interpreter