Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


HOMEWORK #3
due Friday, Sept 21 by 5:00pm

Guidelines for completing and submitting homework
Refer to the first two paragraphs on the Grading Info page for all the details.  Briefly, you may not collaborate with your classmates while writing homework programs.  However, you may certainly consult Spencer on Thursday evenings or Dr. V on Friday afternoons as you create your programs.  (Email your program to me first to check that I'm in the office.)  Other QRC mentors may also be able to help out, depending on their experience with Python.  Once you have completed your program, or made as much progress as possible, email your program as an attachment to svandervelde@stlawu.edu.

Assignment
To begin, create a new document in Komodo and include these comments at the top
# Your full name
# Homework #3, Sept 21, 2012
# Individuals providing assistance, if any

Then save your file using the format LastNameHW3.py.

Now write a program that performs the two tasks described below.  One of them requires a for loop, the other needs a while loop.  (You decide which one is which.)

  • The first part of your program will print a sequence of random two-digit numbers on a single line until it reaches lucky number 88.  (Be sure to include 88 as the last number in your list.)  The program should keep track of the number of tries it took to reach 88, and print a sentence informing the user of this quantity. 
    FOR FUN: 
    I will record the number of tries for each person as I evaluate your homework and award prizes to the students whose programs happened to take the shortest and longest time to hit lucky number 88.

  • Now skip down five blank lines using a single print statement.

  • The second part of your program should briefly tell the user all about the unit of measure known as a firkin.  (This was an actual weight; you should look it up.)  Then it should ask for a number from 1 to 20.  Finally, the program should create a neatly formatted chart that converts firkins to pounds and kilograms, up to the number of firkins requested by the user.  (So if 7 is entered, there will be seven rows in the chart, showing 1 firkin, 2 firkins, ..., up to 7 firkins.)