import math import turtle name = raw_input("What is your name? ") height = int(raw_input("What is your triangle's height? ")) base = int(raw_input("What is your triangle's base? ")) area = base * height / 2.0 print "The area of " + name + "'s triangle is: " + str(area) print "Now let's draw it with a turtle object!" franklin = turtle.Turtle() franklin.color('red') franklin.begin_fill() # draw bottom edge franklin.forward(base) # evaluate turn radians = math.atan(float(height)/base) degrees = math.degrees(radians) turn_angle = 180 - degrees franklin.left(turn_angle) # evaluate hypotenuse hypo_length = math.sqrt(base**2 + height**2) franklin.forward(hypo_length) # turn to go down where turtle started franklin.left(180 - (180 - (90 + degrees))) franklin.forward(height) franklin.end_fill() turtle.done() # IMPORTANT: always add this last line in turtle program # Note: function in the turtle module, not on turtle object