Skip to content

Instantly share code, notes, and snippets.

@chicagowebmanagement
Last active April 29, 2019 00:49
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/19ced05c0b86f500f6101f55bf0eea59 to your computer and use it in GitHub Desktop.
Save chicagowebmanagement/19ced05c0b86f500f6101f55bf0eea59 to your computer and use it in GitHub Desktop.
Create a hexagon class and calculate its area
"""
Author: Patrick Elward
Date: 04/28/2019
Make a Hexagon class with a method called calculate_perimeter that calculates and returns its perimeter.
Then create a Hexagon object, call calculate_perimeter on it, and print the result.
"""
import math
class Hexagon:
def __init__(self,s1,s2,s3,s4,s5,s6):
self.s1 = s1
self.s2 = s2
self.s3 = s3
self.s4 = s4
self.s5 = s5
self.s6 = s6
def cal_perimeter(self):
return self.s1+ self.s2 + self.s3 + self.s4 + self.s5 + self.s6
print(cal_perimeter)
hex=Hexagon(3,4,3,5,4,2)
print(hex.cal_perimeter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment