Skip to content

Exercise Hello World

Kenny Yu edited this page Nov 4, 2013 · 2 revisions

Prereqs

  1. Make sure you have git installed
  2. Make sure you have a github account.
  3. Make sure you have your ssh keys setup. See here for help

Get our code

  1. Go to our bootcamp repository page, and click the Fork button at the top right to make your own fork of our repository.

  2. Once you've forked our repo, there should be a clone URL link on the bottom right of the page of the format: [email protected]:username/bootcamp-python.git. Copy that link.

  3. In your command line, enter this: git clone [email protected]:username/bootcamp-python.git. This should create a bootcamp-python directory on your computer. Type cd bootcamp-python && ls, and you should see an exercise-hello directory. Go into that directory.

Your first python program

Whenever you learn a programming language for the first time, the first program you ever write is to print out "hello world" to the screen!

Open up hello.py and follow the instructions in that file. When you are done, run

python hello.py

to run your program! To make sure your program matches out expected output:

./test.sh

Your second python program

Make a new file called script.py. Copy the contents below into that file:

#!/usr/bin/env python
print "this is a python script!"

Now give it executable permissions:

chmod +x script.py

The combination of the #!/usr/bin/env python line in the file and executable permissions allows us to directly run the program without needing to type python. Now, we can do this to run the program:

./script.py

Commit your changes and make a pull request

Now to make sure your keep a snapshot of your work in history, run these commands in the shell:

git add hello.py
git commit -m "finished hello world example"
git add script.py
git commit -m "created python script"
git push origin master

Make a pull request

  1. Go to our bootcamp repository page and click Pull Requests on the right.

  2. Click the green New pull request button.

  3. Click Edit. For base fork: select hcs/bootcamp-python. For head fork: select username/bootcamp-python and for compare:, select master. Then hit Click to create a pull request` and hit OK. This will create a pull request with your changes.

  4. Remember the URL that you get redirected to. As you complete exercises later in the bootcamp and push your changes to github, your pull request will automatically be updated with all your work!

Finish Bootcamp

Go back home