Название: Python For Kids For Dummies
Автор: Scott Brendan
Издательство: John Wiley & Sons Limited
Жанр: Зарубежная образовательная литература
Серия: For Dummies
isbn: 9781119110859
isbn:
>>> my_second_message = 'This name is a little long. Ideally, try to keep the name short, but not too short.'
This code doesn’t have … or >>> at the start of the second or third line. This means you’re supposed to type it all in before pressing Enter. Only press Enter after typing too short.' at the end, not after typing little long. and but not.
✓ Sometimes the output on your computer may look a little different from what you see in this book. For example, when you run a program in later projects, you might see a restart line. On my screen, all the following text is on a single line:
>>> ================================ RESTART ================================
✓ In Project 4 you see how to automatically indent your code. Until then, each time you need to indent code, do it by pressing the spacebar four times before you add your code. If you have to indent code two levels, press the spacebar eight times (that’s two levels of indent by four spaces per level) before typing your code, and so on. You need to do this for each line of the indented code.
✓ When I’m explaining how code works, I often provide a code template – an outline of how to use the code. A sample template is: help([object name]). In this template, the keyword is help, and it needs to be followed by a pair of parentheses. The square brackets indicate something which is optional. The italics mean you need to fill in. Everything not in italics, type it just like it looks. Using this template, the code help(help) works (it gets help on the help keyword), and so does help(), with nothing inside the parentheses (since [object name] was optional).
✓ Web addresses (URLs) and programming code are in monofont. If you’re reading this book on a device connected to the Internet, you can click the address to visit that website. Try it: www.dummies.com.
✓ Sometimes you need to choose something from a menu. I’m not talking about a burger and fries. I mean actions. For example, I might ask you to choose File ⇒ New File. This means that you go to the File menu and choose New File from it.
✓ The word Ctrl means the Ctrl key on your keyboard. Ctrl+A means that you press the key marked Ctrl while you press the A key. All at the same time. Then release both keys. If you’re using a Mac, your keyboard has a control key – use it. Ctrl-A means press the control key down and press the A key. Then release both keys. Don’t use the option or command keys.
✓ If you’re using a Mac, assume that when I say Enter key, it means the Return key on your keyboard.
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.
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.
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.
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.