title: Python 3 - graphicalTriangle - string formatting/functions
body: <p>was wondering if anyone can point out my error in the last string (area,perimeter) - any assistance would be greatly appreciated. )</p>
  
  <pre><code>message = Text(Point(5, 0.5),"The perimeter is: {0:0.2f}".format(perimeter))
  message.draw(win)
  message2 = Text(Point(5, 1),"The area is: {0:0.2f}".format(a))
  message2.draw(win)
  </code></pre>
  
  <p>#### Full Code #####</p>
  
  <pre><code># Program: triangle.py
  import math
  from graphics import *
  
  def square(x):
      return x * x
  
  def distance(p1, p2):
      dist = math.sqrt(square(p2.getX() - p1.getX()) + square(p2.getY() - p1.getY()))
      return dist
  
  def perimeter():
      # Calculate the perimeter of the triangle
      perimeter = distance(p1,p2) + distance(p2,p3) + distance(p3,p1)
      return perimeter
  
  def area():
      # Calculate the area of the triangle
      base = (distance(p3, p1) * (1 / 2))
      height = ((base) ** 2) - (distance(p1, p2) ** 2)
      h = math.sqrt(square(height))
      a = ((1/2) * (base) * h)
      return a
  
  def main():
      win = GraphWin("Draw a Triangle")
      win.setCoords(0.0, 0.0, 10.0, 10.0)
      message = Text(Point(5, 0.5), "Click on three points")
      message.draw(win)
  
      # Get and draw three vertices of triangle
      p1 = win.getMouse()
      p1.draw(win)
      p2 = win.getMouse()
      p2.draw(win)
      p3 = win.getMouse()
      p3.draw(win)
  
      # Use Polygon object to draw the triangle
      triangle = Polygon(p1,p2,p3)
      triangle.setFill("black")
      triangle.setOutline("blue")
      triangle.draw(win)
  
  
      message = Text(Point(5, 0.5),"The perimeter is: {0:0.2f}".format(perimeter))
      message.draw(win)
      message2 = Text(Point(5, 1),"The area is: {0:0.2f}".format(a))
      message2.draw(win)
  
      # Wait for another click to exit
      win.getMouse()
      win.close()
  
  main()
  </code></pre>