Computer Science I for non-majors by James Tam Return to the course web page

CPSC 217: Assignment 1

Due Friday October 4 at 4 PM

Raw score Letter
27 - 28 A
25 - 26 A-
23 - 24 B+
21 - 22 B
19 - 20 B-
17 - 18 C+
15 - 16 C
13 - 14 C-
11 - 12 D+
 9 - 10 D
  < 9 F

New Concepts to be applied for the assignment

Part I: Introduction to UNIX, using common commands (15 marks)

On the UNIX workstations in the Computer Science lab complete the following steps. (JT: creating a typescript file literally records everything - shown onscreen as well as every character that you type - into a text file. Pressing the backspace or delete key will not delete what's recorded into the file, instead that keyboard character will be translated to a gibberish character. If you make a typographical error then DON'T try to delete it during the typescript. Instead just hit enter once or twice - so there will be a few blank lines in the script file - and then re-enter the command properly. Also you will create a directory called '217' under your home directory, this is not the same as the official course directory which is located under /home/courses/217. Don't mix the two up!)

  1. Login to your UNIX account*

  2. Start a script session *

  3. Show the contents of your home directory (1 mark)

  4. Show your location (path) in the UNIX file system (1 mark)

  5. Make a new directory called '217' (1 mark)

  6. Show the contents of your home directory (1 mark)

  7. Go to the official course directory for CPSC 217 (/home/courses/217) (1 mark)

  8. Show the contents of the official CPSC 217 directory (1 mark)

  9. Show your location (path) in the UNIX file system (1 mark)

  10. Go to the directory for the CPSC 217 Assignment 1 (/home/courses/217/assignments/assignment1) (1 mark)

  11. Display the contents of the file called 'index.txt' onscreen.  Show the file one screen a screen at a time (with a prompt for the user to continue) rather than all at once.  [JT's comment: This step may result in a small amount of 'garbage' or nonsense text appearing on your paper printout.  If the garbage only appears for this step (partway through the display of this file) and/or each of your steps is clear enough for your marker to see each distinct step then you can still get full marks for this assignment. Take away learning: some programs - like the Python translator or the typescript program - will try to translate everything into a text character. In some cases a gibberish text character will be the result because the translation cannot be properly completed] (1 mark)

  12. Try to delete the 'index.txt' file [JT's Hint: you aren't supposed to be able to complete this step successfully but instead you should get an error message. Take away learning: you only have limited file permissions in the course directory] (1 mark)

  13. Copy the 'index.txt' file to the newly created ‘217’ directory that you created in your home directory (1 mark)

  14. Go to the '217' directory that is located in your home directory (1 mark)

  15. Show the contents of the ‘217’ directory.  (It should include the file 'index.txt' now.) (1 mark)

  16. Delete the 'index.txt' file from your 217 directory [JT's comment: it should work now because it's a directory that you created] (1 mark)

  17. Show the contents of the ‘217’ directory.  (It should include the file 'index.txt' now.) (1 mark)

  18. End the script session*

  19. Submit your assignment (the file called "typescript" using the submission mechanism described on the course web page [UNIX submit program]).*

The lines marked with a star '*' don't directly yield any marks but must still be completed in order for Part 1 of the assignment to be marked. You will either receive full marks on Part 1 or a list of the steps which were incorrectly completed.

Part II: Creating your first Python program (13 marks)

You are to write a Python program that will use the 'print()' function to display information about the planets in our solar system1 in the following format:

Each planet's information will be displayed by it's own print statement: print("%s %s," %(<String for planet name>, <String for planet diameter>). You need to figure out how to use the format specifiers in order to get your program output to match the output shown in the image. In the assignment one directory you will find the code for the starting program 'planets.py' that you will copy to your home directory and modify. The alignment should be implemented by using the 'field width' property of the print function and not by manually inserting spaces (this is referred to as 'hard coding'). The only hard coded space allowed is the separator between columns.

Submit your Python program using the submission mechanism described on the course web page [UNIX submit program]).

1 Source "Universe" by Kaufmann W.J. III (WH Freeman and Company 1985)

Features for Part 2

Marks

Displays the planetary information shown in the table (0.25 per row)

3

A space separates out the planet names from the planet diameters (all over nothing for the marks)

1

The planet column is right aligned by setting the field width property (no marks for hard-coding spaces between quotes)

4

The diameter column is left aligned by setting the field width property (no marks for hard-coding spaces  between quotes)

4

The end of each row is marked with a comma (all or nothing for the marks)

1

TOTAL

13