Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Mini-Assignment #1

Due Monday September 22 at 4 PM

New Concepts to be applied for the assignment

Description

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).

Submitting your work:

  1. Assignments (source code/'dot-py' file) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

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

 

Mapping of Raw score to grade point

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