Computer Science I for majors by James Tam |
Get a copy of the starting program 'planets.py' which is located in the UNIX under (/home/231/assignments/mini_assignment1) or can be downloaded [here]. Each planet's information will be displayed by its own print() statement: print("%s %s," %(<String for planet name>, <String for planet diameter>). Modify this program in the following ways: (1) right align the names of the planets (2) left align the diameters of the planets. The output should match the screenshot shown below. The alignment should be implemented by using the 'field width' property of format specifiers 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. It is not recommended that you use the built in Python 'format()' function. (Many programming languages such as 'C' and Java don't include such a function so explicitly specifying the placeholders will make it easier to learn those languages in the future). Finally you need to fill your the contact information (located at the top of the file).
Feature |
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 |
Contact information added in the documentation |
3 |
TOTAL |
16 |
Raw score | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Grade point | 4.0 | 3.85 | 3.7 | 3.5 | 3.3 | 3.15 | 3.0 | 2.85 | 2.7 | 2.5 | 2.3 | 2.15 | 2.0 | 1.7 | 1.3 | 1.0 | 0 |