-
Notifications
You must be signed in to change notification settings - Fork 1
/
gu-ito-7.py
49 lines (31 loc) · 1.02 KB
/
gu-ito-7.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''You are tasked with writing a program to calculate and print the area and circumference of a circle given its radius r units. Implement a class named 'Circle' without any parameter in its constructor.
Input:
The input consists of a single line containing an integer r representing the radius of the circle.
Output:
Output the area and circumference of the circle. Round the output to one decimal value.
Sample Input:
3
Sample Output:
28.3
18.8'''
import math
class Circle:
#..... YOUR CODE STARTS HERE .....
def area(self,radius):
a=math.pi*radius*radius
a=round(a,1)
return a
def circumference(self,radius):
c=2*math.pi*radius
c=round(c,1)
return c
#..... YOUR CODE ENDS HERE .....
def main():
circle = Circle()
# Input for the radius of the circle
r = int(input())
# Calculate and print the area and circumference of the circle
print(circle.area(r))
print(circle.circumference(r))
if __name__ == "__main__":
main()