practice1-spring11

# practice1-spring11 - Test 1 Practice: Compsci 06 Owen...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Test 1 Practice: Compsci 06 Owen Astrachan February, 2011 Name: (1 point) NetID/Login: Honor code acknowledgment (signature) value grade Problem 1 20 pts. Problem 2 10 pts. Problem 3 10 pts. Problem 4 20 pts. TOTAL: 60 pts. This test has 9 pages, be sure your test has them all. Do NOT spend too much time on one question — remember that this class lasts 75 minutes. The last page is blank, if you use it make a note for the problem. In writing code you do not need to worry about specifying the proper import statements . Don’t worry about getting function or method names exactly right. Assume that all libraries and packages we’ve discussed are imported in any code you write. 1 PROBLEM 1 : ( Won’t You Take Me to? ) Part A Write the function totalBill used to compute the bill presented to customers at a restaurant. If the number of people dining is six or greater an automatic 18% gratuity should be added to the bill, otherwise the bill is unchanged. For example: call return value totalBill(80.00,5) 80.0 totalBill(80.00,6) 94.40 totalBill(100.0,10) 118.0 Complete the function below. def totalBill(bill, customers): """ bill is a float, customers an int, return the total to charge based on these values """ Part B The area of a triangle with sides whose lengths are a,b,c can be computed using Hero’s formula as p s * ( s- a ) * ( s- b ) * ( s- c ) whwere s is the semi-perimeter or ( a + b + c ) 2 . Complete function triangleArea using the formula to return the area of a triangle whose sides are given by the float parameters a,b,c def triangleArea(a,b,c): """ return area of triangle whose sides are floats a,b,c """ 2 Part C Write the function...
View Full Document

## This document was uploaded on 01/17/2012.

### Page1 / 8

practice1-spring11 - Test 1 Practice: Compsci 06 Owen...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online