Skip to content

Instantly share code, notes, and snippets.

@chicagowebmanagement
Created April 29, 2019 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chicagowebmanagement/d012f31a9a4a04c01d4eb23a2b8336be to your computer and use it in GitHub Desktop.
Save chicagowebmanagement/d012f31a9a4a04c01d4eb23a2b8336be to your computer and use it in GitHub Desktop.
create a class triangle and return its area
"""
Author: Patrick Elward
Date: 04/28/2019
Create a Triangle class with a method called area that calculates and returns its area.
Then create a Triangle object, call area on it, and print the result.
"""
import math
class Triangle:
def __init__(self,h,b):
self.height=h
self.base=b
self.a= (b*0.5)*h
area=Triangle(6,4)
print(area.a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment