Skip to content

Instantly share code, notes, and snippets.

@raeq
Created May 2, 2021 11:04
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 raeq/7c1c4fa0ea410b853ca50885fadb11d2 to your computer and use it in GitHub Desktop.
Save raeq/7c1c4fa0ea410b853ca50885fadb11d2 to your computer and use it in GitHub Desktop.
Calculate the area of circles or squares.
def area(any_object):
if isinstance(any_object, Circle):
return math.pi * (math.pow(any_object.radius, 2))
elif isinstance(any_object, Square):
return (math.pow(any_object.length, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment