Skip to content

Instantly share code, notes, and snippets.

@chicagowebmanagement
Created April 29, 2019 00:02
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/5d4399b6d29e514c09e07bc364d67ce3 to your computer and use it in GitHub Desktop.
Save chicagowebmanagement/5d4399b6d29e514c09e07bc364d67ce3 to your computer and use it in GitHub Desktop.
class circle and display area for a given input radius
"""
Author: Patrick Elward
Date: 04/28/2019
. Create a Circle class with a method called area that calculates and returns its area.
Then create a Circle object, call area on it, and print the result. Use Python's pi function in the built-in math module.
"""
import math
class Circle():
def __init__ (self,r):
self.r=r
self.area=math.pi * r**2
circle=Circle(5)
print(circle.area)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment