Created
April 29, 2019 00:02
-
-
Save chicagowebmanagement/5d4399b6d29e514c09e07bc364d67ce3 to your computer and use it in GitHub Desktop.
class circle and display area for a given input radius
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 | |
. 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