-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle.py
40 lines (25 loc) · 972 Bytes
/
circle.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
# Problem Statement:- Python script to create a circle, calculate its area and circumference and write it on a text file
class circle:
def __init__(self,):
self.radius = int(input("Enter the radius:"))
def area(self):
return 3.14*self.radius*self.radius
def circumference(self):
return 3.14 *2*self.radius
def dwrite(var1,var2,var3):
file1 = open("detail.txt","a")
datarow = "{},{},{}\n".format(var1,var2,var3)
file1.write(datarow)
file1.close()
print("write operation done successfully")
c1 = circle()
area1 = c1.area()
circumference1 = c1.circumference()
radius1 = c1.radius
var1 = "Radius :{} cm".format(radius1)
var2 = "Area : {} sq cm".format(area1)
var3 = "Circumference : {} cm".format(circumference1)
dwrite(var1,var2,var3)
print("Radius: {} cm".format(radius1))
print("Area:{} sq cm".format(area1))
print("Circumference: {} cm".format(circumference1))