Python program to find the area and circumference of Circle
Problem Definition:
Write a python program that has a class named Circle. Use a class variable to define the value of a constant PI. Use this class variable to calculate the area and circumference of a circle with the specified radius.
Video Tutorial
Source code of Python program to find the area and circumference of Circle
class Circle: PI = 3.142 def __init__(self, radius): self.radius = radius def area (self): return (Circle.PI * self.radius * self.radius) def circumference(self): return (2 * Circle.PI * self.radius) r = int(input("Enter the radius of circle")) c1 = Circle(r) print ("The area of C1 circle is: ", c1.area()) print ("Circumference of C1 Circle is: ", c1.circumference()) print("") r = int(input("Enter the radius of circle")) c2 = Circle(r) print ("Area of C1 circle is: ", c2.area()) print ("Circumference of C1 Circle is: ", c2.circumference())
Output:
Enter the radius of circle 5
The area of C1 circle is: 78.55
Circumference of C1 Circle is: 31.419999999999998
Enter the radius of circle 6
The area of C1 circle is: 113.112
Circumference of C1 Circle is: 37.704
Summary
This article discusses, how to write a Python program to find the area of the Circle. Subscribe to our YouTube channel for more videos and like the Facebook page for regular updates.