Remember, you should have spent a good amount of time in Exercise 0 learning how to install a text editor, run the text editor, run the Terminal, and work with both of them. If you haven't done that then do not go on. You will not have a good time. This is the only time I'll start an exercise with a warning that you should not skip or get ahead of yourself.
Type the above into a single file named ex1.py. This is important as python works best with files ending in .py.
1 2 3 4 5 6 7 | print "Hello World!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay! Printing.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
|
If you are on Mac OSX then this is what your text editor might look like if you use TextWrangler:
If you are on Windows using Notepad++ then this is what it would look like:
Don't worry if your editor doesn't look exactly the same, the key points are:
Then in Terminal run the file by typing:
python ex1.py
If you did it right then you should see the same output I have below. If not, you have done something wrong. No, the computer is not wrong.
On Max OSX in Terminal you should see this:
On Windows in PowerShell you should see this:
You may see different names, the name of your computer or other things before the python ex1.py but the important part is that you type the command, and you saw the output the same as I have.
If you have an error it will look like this:
1 2 3 4 5 | $ python ex/ex1.py
File "ex/ex1.py", line 3
print "I like typing this.
^
SyntaxError: EOL while scanning string literal
|
It's important that you can read these since you will be making many of these mistakes. Even I make many of these mistakes. Let's look at this line-by-line.
Warning
If you are from another country, and you get errors about ASCII encodings, then put this at the top of your python scripts:
# -- coding: utf-8 --
It will fix them so that you can use unicode UTF-8 in your scripts without a problem.
You will also have Extra Credit. The Extra Credit contains things you should try to do. If you can't, skip it and come back later.
For this exercise, try these things:
From now on, I won't explain how each exercise works unless an exercise is different.
Note
An 'octothorpe' is also called a 'pound', 'hash', 'mesh', or any number of names. Pick the one that makes you chill out.