Part 0: Getting Started. Basics
A basic computing course, covering both an introduction to using a computer
and to programming (e.g.,
CS 30),
is a prerequisite. In practice, though, not everyone is familiar
with that material, so we begin with an “Assignment 0” that
involves logging onto the computer and entering and running very simple
programs. We provide tutorials on the linux operating system used in the
Physics Department computer lab, for those who will do their work there.
Exercises
- Log onto your computer account and make sure it works.
- At the command line, set up your Python environment (EPD 7.3)
by running:
122setup
- When needed, use the Firefox browser:
firefox16
-
If you are not already familiar with an editor, read one of the tutorials on
vi commands
here.
- Open the file AddTwoNumbers.py here and type
in the Python program that reads in two numbers and adds them.
NOTE: Nested statements are indented. Every indentation must be four contiguous
spaces. Two indentations will be eight contiguous spaces.
- Open the second
file FirstPrimes.py here and type in the program
that prints the first dozen or so prime numbers.
IMPORTANT: Please do not cut and paste the programs. Spend the 5-10 minutes
it takes to type them in yourself, especially if you are not so familiar with
an editor and with Python. The reason we ask you to do this is that it will
provide useful practice. For example, if you have a typo in your code, you'll
get experience with the sorts of error messages Python gives and how to find
and eliminate the problems. This will be useful later.
- Run your programs, using:
python AddTwoNumbers.py
and
python FirstPrimes.py
- Once your programs are running, pick one and change one of the indented
lines from identing four spaces to three spaces. What happens when you run it?
Repair the file so that it runs again.
- Practice using some of the other basic linux commands. For example, list
the files in your directory. Make a copy of the files you created
above and the like.
- Email the files you created to the TA.
Table of Contents