-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcircle.py
141 lines (104 loc) · 3.53 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# The circle defines a class that performs calculations related to circles.
import math
class Circle:
"""
A class representing a circle.
Attributes:
radius (float): The radius of the circle.
scalingFactor (float): The scaling factor for resizing the circle.
Methods:
calculate_area(): Calculates the area of the circle.
resize_circle(new_radius): Resizes the circle by changing its radius.
calculate_circumference(): Calculates the circumference of the circle.
set_radius(r): Sets the radius of the circle.
get_radius(): Returns the radius of the circle.
set_scalingFactor(k): Sets the scaling factor for resizing the circle.
get_scalingFactor(): Returns the scaling factor for resizing the circle.
"""
def __init__(self):
self.radius = 1.0
def calculate_area(self):
"""
Calculates the area of the circle.
Returns:
float: The area of the circle.
"""
return math.pi * self.radius**2
def resize_circle(self, new_radius):
"""
Resizes the circle by changing its radius.
Parameters:
new_radius (float): The new radius of the circle.
"""
self.radius = new_radius
def calculate_circumference(self):
"""
Calculates the circumference of the circle.
Returns:
float: The circumference of the circle.
"""
return 2*math.pi*self.radius
def set_radius(self, r):
"""
Sets the radius of the circle.
Parameters:
r (float): The radius of the circle.
"""
self.radius = r
def get_radius(self):
"""
Returns the radius of the circle.
Returns:
float: The radius of the circle.
"""
return self.radius
def set_scalingFactor(self, k):
"""
Sets the scaling factor for resizing the circle.
Parameters:
k (float): The scaling factor for resizing the circle.
"""
self.scalingFactor = k
def get_scalingFactor(self):
"""
Returns the scaling factor for resizing the circle.
Returns:
float: The scaling factor for resizing the circle.
"""
return self.scalingFactor
# The circle defines a class that perform
# calculations related to circles.
import math
class Circle:
def __init__(self):
self.__radius = 1.0
def calculate_area(self):
return math.pi * self.__radius**2
def resize_circle(self, new_radius):
self.__radius = new_radius
def calculate_circumference(self):
return 2*math.pi*self.__radius
def set_radius(self, r):
self.__radius = r
def get_radius(self):
return self.__radius
def set_scalingFactor(self, k):
self.__scalingFactor = k
def get_scalingFactor(self):
return self.__scalingFactor
def __init__(self):
self.radius = 1.0
def calculate_area(self):
return math.pi * self.radius**2
def resize_circle(self, new_radius):
self.radius=new_radius
def calculate_circumference(self):
return 2*math.pi*self.radius
def set_radius(self,r):
self.radius=r
def get_radius(self):
return self.radius
def set_scalingFactor(self, k):
self.__scalingFactor=k
def get_scalingFactor(self):
return self.__scalingFactor