Skip to content

Commit 8216f14

Browse files
authored
magic class
1 parent 5b5365d commit 8216f14

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python3
2+
"""Define a MagicClass matching exactly a bytecode provided by Holberton."""
3+
4+
import math
5+
6+
7+
class MagicClass:
8+
"""Represent a circle."""
9+
10+
def __init__(self, radius=0):
11+
"""Initialize a MagicClass.
12+
13+
Arg:
14+
radius (float or int): The radius of the new MagicClass.
15+
"""
16+
self.__radius = 0
17+
if type(radius) is not int and type(radius) is not float:
18+
raise TypeError("radius must be a number")
19+
self.__radius = radius
20+
21+
def area(self):
22+
"""Return the area of the MagicClass."""
23+
return (self.__radius ** 2 * math.pi)
24+
25+
def circumference(self):
26+
"""Return The circumference of the MagicClass."""
27+
return (2 * math.pi * self.__radius)

0 commit comments

Comments
 (0)