This exercise has no code. It is simply the exercise you complete to get your computer to run Python. You should follow these instructions as exactly as possible. If you have problems following the written instructions, then watch the included videos for your platform.
Warning!
If you do not know how to use PowerShell
on Windows, Terminal
on macOS or bash
on Linux then you need to go learn that first. You should do the exercises in the appendix first before continuing with these exercises.
Do the following tasks to complete this exercise:
1. Go to https://www.python.org/downloads/release/python-360/ and download the version titled “Mac OS X 64-bit/32-bit installer.” Install it like you would any other software.
2. Go to https://atom.io with your browser, get the Atom
text editor, and install it. If Atom
does not suit you, then see the Alternative Text Editors section at the end of this exercise.
3. Put Atom
(your text editor) in your dock, so you can reach it easily.
4. Find your Terminal program. Search for it. You will find it.
5. Put your Terminal in your dock as well.
6. Run your Terminal program. It won’t look like much.
7. In your Terminal program, run python3.6
. You run things in Terminal by just typing the name and hitting RETURN.
8. Type quit()
, Enter
, and get out of python3.6
.
9. You should be back at a prompt similar to what you had before you typed python
. If not, find out why.
10. Learn how to make a directory in the Terminal.
11. Learn how to change into a directory in the Terminal.
12. Use your editor to create a file in this directory. Make the file, Save
or Save As...
, and pick this directory.
13. Go back to Terminal using just the keyboard to switch windows.
14. Back in Terminal, list the directory with ls
to see your newly created file.
Here’s me doing this on my macOS computer in Terminal. Your computer might be different but should be similar to this.
$ python3.6
Python 3.6.0 (default, Feb 2 2017, 12:48:29)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang–700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
~ $ mkdir lpthw
~ $ cd lpthw
lpthw $ ls
# ... Use your text editor here to edit test.txt....
lpthw $ ls
test.txt
lpthw $
1. Go to https://atom.io with your browser, get the Atom
text editor, and install it. You do not need to be the administrator to do this.
2. Make sure you can get to Atom
easily by putting it on your desktop and/or in Quick Launch
. Both options are available during setup. If you cannot run Atom
because your computer is not fast enough, then see the Alternative Text Editors section at the end of this exercise.
3. Run PowerShell
from the Start menu. Search for it, and just press Enter
to run it.
4. Make a shortcut to it on your desktop and/or Quick Launch
for your convenience.
5. Run your PowerShell
program (which I will call Terminal later). It won’t look like much.
6. Download Python 3.6 from https://www.python.org/downloads/release/python-360/ and install it. Be sure to check the box that says to add Python 3.6 to your path.
7. In your PowerShell
(Terminal) program, run python
. You run things in Terminal by just typing the name and pressing Enter
. If you type python
and it does not run, then you have to reinstall Python and make sure you check the box for “Add python to the PATH.” It’s very small so look carefully.
8. Type quit()
, and press Enter
to exit python.
9. You should be back at a prompt similar to what you had before you typed python
. If not, find out why.
10. Learn how to make a directory in the PowerShell
(Terminal).
11. Learn how to change into a directory in the PowerShell
(Terminal).
12. Use your editor to create a file in this directory. Make the file, Save
or Save As...
, and pick this directory.
13. Go back to PowerShell
(Terminal) using just the keyboard to switch windows. Look it up if you can’t figure it out.
14. Back in PowerShell
(Terminal), list the directory to see your newly created file.
From now on, when I say “Terminal” or “shell” I mean PowerShell
, and that’s what you should use. When I run python3.6
you can just type python
.
> python
>>> quit()
> mkdir lpthw
> cd lpthw
... Here you would use your text editor to make test.txt in lpthw ...
>
> dir
Volume in drive C is
Volume Serial Number is 085C-7E02
Directory of C:Documents and Settingsyoulpthw
04.05.2010 23:32 <DIR> .
04.05.2010 23:32 <DIR> ..
04.05.2010 23:32 6 test.txt
1 File(s) 6 bytes
2 Dir(s) 14 804 623 360 bytes free
>
It is still correct if you see different information than mine, but yours should be similar.
Linux is a varied operating system with many different ways to install software. I’m assuming if you are running Linux then you know how to install packages, so here are your instructions:
1. Use your package manager to install Python 3.6, and if you can’t, then download source from https://www.python.org/downloads/release/python-360/ and build from source.
2. Use your Linux package manager, and install the Atom text editor. If Atom
does not suit you, then see the Alternative Text Editors section at the end of this exercise.
3. Make sure you can get to Atom
easily by putting it in your window manager’s menu.
4. Find your Terminal
program. It could be called GNOME Terminal
, Konsole
, or xterm
.
5. Put your Terminal
in your dock as well.
6. Run your Terminal
program. It won’t look like much.
7. In your Terminal
program, run python3.6
. You run things in Terminal
by just typing the command name and pressing Enter
. If you can’t run python3.6
, try running just python
.
8. Type quit()
and press Enter
to exit python.
9. You should be back at a prompt similar to what you had before you typed python
. If not, find out why.
10. Learn how to make a directory in Terminal
.
11. Learn how to change into a directory in Terminal
.
12. Use your editor to create a file in this directory. Typically, you will make the file, Save
or Save As...
, and pick this directory.
13. Go back to Terminal using just the keyboard to switch windows. Look it up if you can’t figure it out.
14. Back in Terminal
, list the directory to see your newly created file.
$ python
>>> quit()
$ mkdir lpthw
$ cd lpthw
# ... Use your text editor here to edit test.txt ...
$ ls
test.txt
$
It is still correct if you see different information than mine, but yours should be similar.
A major part of this book is learning to research programming topics online. I’ll tell you to “search for this on the internet,” and your job is to use a search engine to find the answer. The reason I have you search instead of just giving you the answer is because I want you to be an independent learner who does not need my book when you’re done with it. If you can find the answers to your questions online, then you are one step closer to not needing me, and that is my goal.
Thanks to search engines such as Google you can easily find anything I tell you to find. If I say, “search online for the python list functions,” then you simply do this:
1. Go to http://google.com.
2. Type: python3 list functions
.
3. Read the websites listed to find the best answer.
You are done with this exercise. This exercise might be hard for you depending on your familiarity with your computer. If it is difficult, take the time to read and study and get through it, because until you can do these very basic things you will find it difficult to get much programming done.
If someone tells you to stop at a specific exercise in this book or to skip certain ones, you should ignore that person. Anyone trying to hide knowledge from you, or worse, make you get it from them instead of through your own efforts, is trying to make you depend on them for your skills. Don’t listen to them, and do the exercises anyway so that you learn how to educate yourself.
A programmer will eventually tell you to use macOS or Linux. If the programmer likes fonts and typography, they’ll tell you to get a macOS computer. If he likes control and has a huge beard, he will (or ze will if you prefer non-gendered pronouns for humans with beards) tell you to install Linux. Again, use whatever computer you have right now that works. All you need is an editor, a Terminal, and Python.
Finally, the purpose of this setup helps you do three things very reliably while you work on the exercises:
1. Write exercises using the text editor.
2. Run the exercises you wrote.
3. Fix them when they are broken.
4. Repeat.
Anything else will only confuse you, so stick to the plan.
Text editors are very important to a programmer, but as a beginner you only need a simple programmer’s text editor. These are different from software for writing stories and books because they work with the unique needs of computer code. I recommend Atom
in this book because it is free and works nearly everywhere. However, Atom
may not run well on your computer, so here are some alternatives to try:
These are ranked in order of most likely to work. Keep in mind that these projects may be abandoned, dead, or not work anymore on your computer. If you try one and it doesn’t work, try another one. I’ve also listed the “Works On” in order of most likely to work, so if you’re on Windows then look at the editors where Windows is listed first in the “Works On” column.
If you already know how to use Vim or Emacs then feel free to use them. If you have never used Vim or Emacs then avoid them. Programmers may try to convince you to use Vim or Emacs, but this will only derail you. Your focus is learning Python, not learning Vim or Emacs. If you try to use Vim and don’t know how to quit, then type :q!
or ZZ
. If someone told you to use Vim, and they didn’t even tell you this, then now you know why you shouldn’t listen to them.
Do not use an Integrated Development Environment (IDE) while you go through this book. Relying on an IDE means that you can’t work with new programming languages until some company decides to sell you an IDE for that language. This means you can’t use that new language until the language is large enough to justify a lucrative customer base. If you are confident you can work with only a programmer’s text editor (like Vim, Emacs, Atom, etc.) then you don’t have to wait for a third party. IDEs are nice in some situations (such as working with a giant existing code base) but being addicted to them will limit your future.
You should also not use IDLE. It has serious limitations in how it works and isn’t a very good piece of software. All you need is a simple text editor, a shell, and Python.
3.138.204.208