All pastes #775637 Raw Edit

Something

public python v1 · immutable
·published 2007-11-15 17:49 UTC
rendered paste body
# week05.py# Daniel Raban, 123456# Writing functionsfrom graphics import *import mathdef calcFutureValue(amount, years):    interestRate = 0.055    for year in range(years):        amount = amount * (1 + interestRate)    return amount def futureValue():    amount = input("Enter an amount to invest: ")    years = input("Enter the number of years: ")    finalValue = calcFutureValue(amount, years)    print "Investing", amount, "pounds for", years, "years", \          "will result in", finalValue, "pounds"def circumferenceOfCircle(radius):    return 2 * math.pi * radiusdef areaOfCircle(radius):    return math.pi * radius**2def circleStats():    radius = input("Enter the radius: ")    circumference = circumferenceOfCircle(radius)    area = areaOfCircle(radius)    print "The circumference is", circumference    print "The area is", areadef drawSquare(n):    print (("*" * n + "\n") * n)def repeatString(s, n):    print(s + "\n") * n    def drawTarget(win, centre):    outer = Circle(centre, 30)    outer.setFill("blue")    outer.draw(win)    mid = Circle(centre, 20)    mid.setFill("yellow")    mid.draw(win)    inner = Circle(centre, 10)    inner.setFill("red")    inner.draw(win)    def drawTargetRange():   win = GraphWin("Target Range", 500, 100)   x = 50   for i in range (5):       drawTarget(win, point(x,50))       x = x + 100def distanceBetweenPoints(p1,p2):    dist = math.sqrt(square(p2.getX() - p1.getX())                     + square(p2.getY() - p1.getY()))    return dist