Computer Science 217
Assignment #1

Mike Jacobson

Due: see Evaluation below



Purpose

To become familiar with Unix and Python, and write a small Python program.

Important Note

Base Conversion

Write a Python program that does four things:

  1. Prompts the user to enter a base 10 number.
  2. Reads a base 10 number from the user.
  3. Converts the base 10 number into base 2 and prints it.
  4. Converts the base 10 number into base 8 and prints it.

You may assume that the number will be positive and will never be larger than 255.

Some sample runs of a solution would look similar to this:

% python as1.py
Enter a base 10 number: 42
42 in base 10 is 0 0 1 0 1 0 1 0 in base 2
42 in base 10 is 0 5 2 in base 8

% python as1.py
Enter a base 10 number: 255
255 in base 10 is 1 1 1 1 1 1 1 1 in base 2
255 in base 10 is 3 7 7 in base 8

% python as1.py
Enter a base 10 number: 0
0 in base 10 is 0 0 0 0 0 0 0 0 in base 2
0 in base 10 is 0 0 0 in base 8

If you know how to use loops, you may use them, but there are no bonus points for doing this.

Hints

Evaluation

You must do two things:

  1. Hand in a printout of your solution to the assignment boxes by 4pm Monday, February 1, 2010. Make sure it has your name and/or student ID number on it, and double-check to ensure you're using the correct assignment box! The assignment boxes are on the second floor of the Math Science building. If your TA is accepting solutions in any other form (e.g., email) then they will let you know - however, you must still observe the deadline.
  2. Demonstrate your solution to your TA in tutorials during the week of February 1. To keep things fair, the solution you demonstrate must be the same as what you handed in on the printout, or you will not be given credit for the demo. Your TA may ask you questions about what the different parts of your solution do, and may also ask you to perform basic Unix commands.
If you do not hand in a printout or if you do not demonstrate your assignment during tutorial time, or both, you cannot be given a grade above a zero on this assignment.

Your printout must show your Python program. Note that you must have a program in a .py file - you cannot turn in a solution that only uses the Python command line.

Your solution must be demonstrated using your account on the CPSC machines.

Tutorials during the week of February 1 are allocated for demos. Your TA is not obliged to see demos outside this time; they have their own schoolwork to do!

The TA has the right to assign a mark of zero for the entire assignment if you fail the demo.

Half of the marks are for functionality (i.e., the demo) and half are for your solution (as shown on the printout). Note that, in keeping with the University's assessment criteria, simply having a working solution does not automatically mean that you get full marks. For example, better solutions will have more readable code.



Michael Jacobson, Jr. 2010-01-19