Last active
April 29, 2019 00:49
-
-
Save chicagowebmanagement/19ced05c0b86f500f6101f55bf0eea59 to your computer and use it in GitHub Desktop.
Create a hexagon class and calculate its area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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