CS110 Introduction to Computing
Fall 2006

Lab Assignment#3

In this assignment you are required to solve two problems (in two separate Python programs).

Assignment:

Problem#1: Write a Python program to simulate an ATM machine. This ATM gives out bills in 20s, 10, 5s, and 1s. Ask the user to enter a dollar amount, calculate how many 20s, 10s, 5s, and 1s the amount will come out as. The ATM will always give out as many 20s as possible, then move on to 10s, and so on. Here is a sample interaction with the program (red is program output(s), blue is user input):

Enter an amount to withdraw (only whole dollar amounts, please) : $853
Your change will be issues in 42 twenties, 1 tens, 0 fives, and 3 ones.

Your program will need to do the computation using the integer divide (/) and modulus (%) operations.

Demonstrate the output of your program for $0, $9, $298, and $999.

Problem#2: Do programming Exercise 17 in Chapter 3 of Zelle (page 74-75). Here is a sample interaction with the resulting program:

This program approximates square roots of a number using Newton's method.
Enter your number:
100
How many iterations should I use? 4

Approximate square root is 10.0304952039
Difference from math.sqrt is -0.0304952038898

Show at least 3 sample runs of your program on values 10, 123456, 982081 for 10, 20, 50 iterations respectively.

What you will need to do

  1. For each problem, do the analysis as described in the text: clearly identify the input(s) and output(s) and the relationship(s) between them.
  2. Write the algorithm to solve each problem and then code it in Python.
  3. Make sure you do the above steps prior to entering the lab (or using your computer).
  4. Test and debug your program until it produces correct results.
  5. When done, print out the final version your your program and also a printout showing your program's output(s) on the example data above.
  6. Hand in your analysis, algorithm, printouts from Step 5.
  7. Make a blog posting saying that you have completed the assignment and also write up any logistical or other issues/questions raised while working on this assignment. Also write about your level of confidence on the concepts learned so far.

Notes:

Add the following line to all your Python programs:

# File: <place name of your program file here>
# Date: <date created>
# Created by: <your name>
# Assignment: <place assignment number here>

Back to CS110 Course Page