A Good First Program

Remember, you should have spent a good amount of time in understanding how to upload a ipython notebook on https://try.jupyter.org/ website. Learn how to switch to python 3 kernel. All the excercise are for python 3. Learn the basics of iPython notebook about cell.

Type the following text into the cell below in the notebook and run. In case of any error try to debug it.

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

In [ ]:

You should see this below the cell: Hello World! Hello Again I like typing this. This is fun. Yay! Printing. I'd much rather you 'not'. I "said" do not touch this.

If you have an error, it will look like this: File "", line 1 print('I "said" do not touch this.' ^ SyntaxError: unexpected EOF while parsing

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.

  1. Here we ran our command in the ipython cell.
  2. Python then tells us that the codey has an error on line.
  3. It then prints this line for us.
  4. Then it puts a ^ (caret) character to point at where the problem is. Notice the missing " closing bracket character?
  5. Finally, it prints out a SyntaxError and tells us something about what might be the error. Usually these are very cryptic, but if you copy that text into a search engine, you will find someone else who’s had that error and you can probably figure out how to fix it.

Study Drills

Each exercise also contains Study Drills. The Study Drills contain things you should try to do. If you can’t, skip it and come back later. For this exercise, try these things:

  1. Make your script print another line.
  2. Make your script print only one of the lines.
  3. Put a “#” (octothorpe) character at the beginning of a line. What did it do? Try to find out what this character does.

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.