Here’s my code:

import math

import time

def y(x,r):

square = x ** 2

return math.sqrt(r – square)

while 1:

n = input(“n “)

i = 0.00

cx = 2.00 / n

area = 0.00

oldTime = time.clock()

while i < n:

x = -1 + (cx * i)

area += y(x,1) * cx

i += 1

piCalc = 2.00 * area

newTime = time.clock()

timeDiff = newTime – oldTime

print piCalc

print "Calculation completed in " + str(timeDiff) + " seconds of CPU time"

I love doing this sort of problem with my students, because lots of them think they might be doctors someday.

]]>Amazing post. i am completely agree with your post. As IB Maths teacher in IB World Academy I know usefulness of pursuing IB in college admissions. ]]>

Person 1: 17.50 + 17.50 -20 = 15 (man walks away with a -$2.50 haircut – nice friend!)

Person 2: 15 + 15 – 20 = 10 (man walks away with a -$5.00 haircut – big jerk!)

Person 3: 10 + 10 -20 = 0 (man walks away with a -$10.00 haircut and cleans out the poor silly barber – thief!!

Person 4: Either very honest or he wants an extra $20.00 in his pocket and a free haircut.

-Bill

]]>