Ad
Code
Diff
  • #!/usr/bin/env python3
    """
    Debugging: FixDatTrash # 2
    """
    
    # constant:
    PI = 3.1415926535897
    
    
    class Calculator:
        """A calculator class."""
    
        def __init__(self, num):
            """Initialize attributes."""
            self.num = num
    
        def calculate_power(self, exp):
            """
            Calculates power of self.num.
            parameter `exp` is the exponent.
            """
            return self.num ** exp
    
        def calculate_square_root(self):
            """Calculates square root of self.num."""
            return self.num ** 0.5
    
        def calculate_cube_root(self):
            """Calculates cube root of self.num."""
            return self.num ** (1 / 3)
    
        def calculate_circumference(self):
            """
            Calculates circumference of circle.
            self.num is the diameter of the circle.
            """
            return PI * self.num
        
        def calculate_circle_area(self):
            """
            Calculates area of circle.
            self.num is the radius of the circle
            """
            return self.num ** 2 * PI
        
    • #!/usr/bin/env python3
    • """
    • Debugging: FixDatTrash # 2
    • """
    • # constant:
    • PI = 3.1415926535897
    • class Calculator:
    • """A calculator class."""
    • def __init__(self, num):
    • """Initialize attributes."""
    • self.num = num
    • def calculate_power(self, exp):
    • """
    • Calculates power of self.num.
    • parameter `exp` is the exponent.
    • """
    • return self.num ** exp
    • def calculate_square_root(self):
    • """Calculates square root of self.num."""
    • return self.num ** 0.5
    • def calculate_cube_root(self):
    • """Calculates cube root of self.num."""
    • return self.num ** (1 / 3)
    • def calculate_circumference(self):
    • """
    • Calculates circumference of circle.
    • self.num is the diameter of the circle.
    • """
    • return PI * self.num
    • def calculate_circle_area(self):
    • """
    • Calculates area of circle.
    • self.num is the radius of the circle
    • """
    • return self.num ** 2 * PI