Introduction to Computer Science
Union College
Spring 2009

## Homework 1 - due Wednesday, April 8, before class

#### 0) Office hours

Come to see me in my office during office hours.
My office is Steinmetz Hall 233.
Office hours are: Monday 2-3pm, Tuesday 2-4pm, Friday 1-2pm.

The purpose of this exercise is that you all know where to find me and that I get some feedback on whether the times of my office hours work for people.

#### 1) Turtle house

Use the turtle library to draw the following picture:

#### 2) Turtle pyramid

Use the turtle library to draw the following picture:

#### 3) Tip, Tax, Total

Write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15 percent tip and a 7 percent sales tax. Display each of these amounts and the total.
(Gaddis, Chapter 2, Programming Exercises No. 8)

#### 4) Distance between circles

Circles are specified by giving the (x- and y-coordinates of the) center of the circle and the radius of the circle. Write a program that asks the user to input a circle (i.e., three numbers representing the x- and y-coordinate of the circle and its radius) and then calculates the distance between the circles. In case the circles overlap, the distance should come out as negative.

To calculate the square root, you can use the function 'sqrt' provided by the library 'math'. So: 'import math' at the top of your program file. And then you can say things like math.sqrt()' - the value of this expression is the square root of the number.