Python For Kids For Dummies. Scott Brendan
Чтение книги онлайн.

Читать онлайн книгу Python For Kids For Dummies - Scott Brendan страница 5

СКАЧАТЬ ⇒ 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)

       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:

      1. Open your Start menu.

      2. Choose All Programs ⇒ Python 2.7.

3. Right-click IDLE (Python GUI). See Figure 1-5.

      4. Select Pin to Start Menu.

      5. Right-click Python (command line).

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

      You can’t use this book unless you can start Python. Click Python (command line) that you pinned to your Start menu.

      

If you haven’t pinned it yet, do it. No, seriously. You can also search for Python in the search bar and click Python (command line) in the Programs section of the results.

You get a window that looks like Figure 1-6.

       Figure 1-6: The Python command line suggests you type help if you want help.

Use Python’s Built-In Documentation

Python comes with its own help. In fact, in Figure 1-6 it even tells you about it in the welcome message. If you type help and press Enter, you get more help options. Type help() (including the parentheses) to get interactive help like what you see in Figure 1-7.

       Figure 1-7: Python’s interactive help is ready for you to type.

      

Once you’re inside the help service, you can get information on any topic. Just type the topic. The help service can’t handle complex queries (like the ones you use to search the Internet), so keep it simple. For example, instead of typing how do I get a range of numbers, type range (and read what it has to say). To quit interactive help, type quit.

      You can write help text for your own programs. You do it in Project 5.

Put the Kibosh on the Python Interpreter

      You can’t use this book unless you can start Python, but you’ll want to stop Python after you’ve started it. If you can’t wait to start programming, skip ahead to Project 2.

      You can put the kibosh on Python СКАЧАТЬ