Computer Science I for non-majors by James Tam | Return to the course web page |
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 |
Login to your UNIX account*
Start a script session *
Show the contents of your home directory (1 mark)
Show your location (path) in the UNIX file system (1 mark)
Make a new directory called '217' (1 mark)
Show the contents of your home directory (1 mark)
Go to the official course directory for CPSC 217 (/home/courses/217) (1 mark)
Show the contents of the official CPSC 217 directory (1 mark)
Show your location (path) in the UNIX file system (1 mark)
Go to the directory for the CPSC 217 Assignment 1 (/home/courses/217/assignments/assignment1) (1 mark)
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)
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)
Copy the 'index.txt' file to the newly created ‘217’ directory that you created in your home directory (1 mark)
Go to the '217' directory that is located in your home directory (1 mark)
Show the contents of the ‘217’ directory. (It should include the file 'index.txt' now.) (1 mark)
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)
Show the contents of the ‘217’ directory. (It should include the file 'index.txt' now.) (1 mark)
End the script session*
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.
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 |