-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path103-magic_class.py
More file actions
28 lines (22 loc) · 800 Bytes
/
103-magic_class.py
File metadata and controls
28 lines (22 loc) · 800 Bytes
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
#!/usr/bin/python3
# 103-magic_calculation.py
# Gedeon Obae Gekonge
"""Define a MagicClass matching exactly a bytecode provided by Holberton."""
import math
class MagicClass:
"""Represent a circle."""
def __init__(self, radius=0):
"""Initialize a MagicClass.
Arg:
radius (float or int): The radius of the new MagicClass.
"""
self.__radius = 0
if type(radius) is not int and type(radius) is not float:
raise TypeError("radius must be a number")
self.__radius = radius
def area(self):
"""Return the area of the MagicClass."""
return (self.__radius ** 2 * math.pi)
def circumference(self):
"""Return The circumference of the MagicClass."""
return (2 * math.pi * self.__radius)