Skip to content

Instantly share code, notes, and snippets.

@chicagowebmanagement
Last active May 20, 2019 16:35
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/f5cbd0bcaa6521e3f8c4d29fa5c6b6e6 to your computer and use it in GitHub Desktop.
Save chicagowebmanagement/f5cbd0bcaa6521e3f8c4d29fa5c6b6e6 to your computer and use it in GitHub Desktop.
Create two classes, rectange and square and display the perimeter of each
"""
Author: Patrick Elward
Date: 04/28/2019
Create Rectangle and Square classes with a method called calculate_perimeter that calculates the perimeter of the shapes they represent.
Create Rectangle and Square objects and call the method on both of them.
"""
import math
class Rectangle:
def __init__(crash,a,b):
crash.a=a
crash.b=b
rectangle_perimeter = b+b+a+a
print("The Rectangle perimeter is " ,rectangle_perimeter)
class Square:
def __init__(crash,c):
crash.c=c
square_perimeter=c+c+c+c
print("The Square perimeter is ",square_perimeter)
Rectangle(4,6)
Square(7)
@chicagowebmanagement
Copy link
Author

testing out 'crash' instead of 'self' to strengthen my OOP skills/knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment