MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / max_parts

Method max_parts

geometry/geometry.py:142–167  ·  view source on GitHub ↗

Return the maximum number of parts that circle can be divided into if cut 'num_cuts' times. >>> circle = Circle(5) >>> circle.max_parts(0) 1.0 >>> circle.max_parts(7) 29.0 >>> circle.max_parts(54) 1486.0 >>> circle.max

(self, num_cuts: float)

Source from the content-addressed store, hash-verified

140 return self.radius * 2
141
142 def max_parts(self, num_cuts: float) -> float:
143 """
144 Return the maximum number of parts that circle can be divided into if cut
145 'num_cuts' times.
146
147 >>> circle = Circle(5)
148 >>> circle.max_parts(0)
149 1.0
150 >>> circle.max_parts(7)
151 29.0
152 >>> circle.max_parts(54)
153 1486.0
154 >>> circle.max_parts(22.5)
155 265.375
156 >>> circle.max_parts(-222)
157 Traceback (most recent call last):
158 ...
159 TypeError: num_cuts must be a positive numeric value.
160 >>> circle.max_parts("-222")
161 Traceback (most recent call last):
162 ...
163 TypeError: num_cuts must be a positive numeric value.
164 """
165 if not isinstance(num_cuts, (int, float)) or num_cuts < 0:
166 raise TypeError("num_cuts must be a positive numeric value.")
167 return (num_cuts + 2 + num_cuts**2) * 0.5
168
169
170@dataclass

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected