Python For Kids For Dummies. Scott Brendan

Читать онлайн.
Название Python For Kids For Dummies
Автор произведения Scott Brendan
Жанр Зарубежная образовательная литература
Серия For Dummies
Издательство Зарубежная образовательная литература
Год выпуска 0
isbn 9781119110859



Скачать книгу

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:

      1. Press Cmd+spacebar to open Spotlight.

      2. Type the word terminal.

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

      The Terminal window opens.

      3. 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:

      1. Visit www.python.org/downloads.

      2. 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.

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

      4. 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:

      1. Visit www.python.org/downloads.

      2. From the menu bar, select Downloads ⇒ Windows.

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

      3. 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.

      4. 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.

      5. 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.

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

      7. 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)