on the center toolbar. You will automatically be placed in your home directory. Typically you do not want to put files here, but rather you want to edit files in a cs21 sub-directory. Use the cd command to get to proper directory. For example, for lab 01, you need to save files in the cs21/labs/01 directory.
onion[~]$ cd cs21/labs/01/ onion[01]$ ls onion[01]$ pwd /home/adas/cs21/labs/01Use TAB-completion to help navigate the directories quickly.
If you get a No such file or directory error when you type cd, double check your spelling, or use mkdir to create the directory that is missing. Instructions for using mkdir will typically be posted on the lab assignment or inclass exercise.
If you get a Not a directory error when you type cd, you went one level too far. See a sample error and fix below:
onion[~]$ cd onion[~]$ ls Desktop/ Documents/ cs21/ onion[~]$ cd cs21/labs/00/bio.txt -bash: cd: cs21/labs/00/bio.txt: Not a directory onion[~]$ cd cs21/labs/00/ onion[00]$ pwd /home/adas/cs21/labs/00 onion[00]$ ls bio.txt onion[00]$
onion[01]$ vim acres_to_yards.pyIf the file already exists, the above command will edit the file. If the file does not exists, the file will be created the first time you save your vim session. Press i to start editing in vim. When you would like to save, type <ESC>:w. To go back to editing, type i again.
Remember the key elements of a basic program:
A full sample program is shown below:
""" A sample python program (Tia Newhall, 9/2/2009) """ def main(): print "welcome to cs21" main()
on the center toolbar again to open a second terminal window. Use cd as described above to navigate to the same directory as the file you are editing. Once in the proper directory, type python followed by the name of your program.
onion[01]$ python acres_to_yards.pyIf there are errors or things you would like to change, go to your vim window and make changes. Don't forget to save your changes before trying to run the program again using python.
Here is some more information about update21 and handin21