


'''simple docstring'''
from math import pi, sqrt, tan


def 			_lowercase       (				UpperCamelCase__       :					float			):
 if side_length < 0:
  raise ValueError('surface_area_cube() only accepts non-negative values'			)
 return 6 * side_length**2


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if length < 0 or breadth < 0 or height < 0:
  raise ValueError('surface_area_cuboid() only accepts non-negative values'			)
 return 2 * ((length * breadth) + (breadth * height) + (length * height))


def 			_lowercase       (				UpperCamelCase__       :					float			):
 if radius < 0:
  raise ValueError('surface_area_sphere() only accepts non-negative values'			)
 return 4 * pi * radius**2


def 			_lowercase       (				UpperCamelCase__       :					float			):
 if radius < 0:
  raise ValueError('surface_area_hemisphere() only accepts non-negative values'			)
 return 3 * pi * radius**2


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if radius < 0 or height < 0:
  raise ValueError('surface_area_cone() only accepts non-negative values'			)
 return pi * radius * (radius + (height**2 + radius**2) ** 0.5)


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if radius_a < 0 or radius_a < 0 or height < 0:
  raise ValueError(
      'surface_area_conical_frustum() only accepts non-negative values'			)
 __A  :		Optional[Any]       =			(height**2 + (radius_a - radius_a) ** 2) ** 0.5
 return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if radius < 0 or height < 0:
  raise ValueError('surface_area_cylinder() only accepts non-negative values'			)
 return 2 * pi * radius * (height + radius)


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if torus_radius < 0 or tube_radius < 0:
  raise ValueError('surface_area_torus() only accepts non-negative values'			)
 if torus_radius < tube_radius:
  raise ValueError(
      'surface_area_torus() does not support spindle or self intersecting tori'			)
 return 4 * pow(UpperCamelCase__,				2			) * torus_radius * tube_radius


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if length < 0 or width < 0:
  raise ValueError('area_rectangle() only accepts non-negative values'			)
 return length * width


def 			_lowercase       (				UpperCamelCase__       :					float			):
 if side_length < 0:
  raise ValueError('area_square() only accepts non-negative values'			)
 return side_length**2


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if base < 0 or height < 0:
  raise ValueError('area_triangle() only accepts non-negative values'			)
 return (base * height) / 2


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if sidea < 0 or sidea < 0 or sidea < 0:
  raise ValueError('area_triangle_three_sides() only accepts non-negative values'			)
 elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
  raise ValueError('Given three sides do not form a triangle'			)
 __A  :		int       =			(sidea + sidea + sidea) / 2
 __A  :		List[Any]       =			sqrt(
     semi_perimeter
     * (semi_perimeter - sidea)
     * (semi_perimeter - sidea)
     * (semi_perimeter - sidea)			)
 return area


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if base < 0 or height < 0:
  raise ValueError('area_parallelogram() only accepts non-negative values'			)
 return base * height


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if basea < 0 or basea < 0 or height < 0:
  raise ValueError('area_trapezium() only accepts non-negative values'			)
 return 1 / 2 * (basea + basea) * height


def 			_lowercase       (				UpperCamelCase__       :					float			):
 if radius < 0:
  raise ValueError('area_circle() only accepts non-negative values'			)
 return pi * radius**2


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if radius_x < 0 or radius_y < 0:
  raise ValueError('area_ellipse() only accepts non-negative values'			)
 return pi * radius_x * radius_y


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					float			):
 if diagonal_a < 0 or diagonal_a < 0:
  raise ValueError('area_rhombus() only accepts non-negative values'			)
 return 1 / 2 * diagonal_a * diagonal_a


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					float			):
 if not isinstance(UpperCamelCase__,				UpperCamelCase__			) or sides < 3:
  raise ValueError(
      'area_reg_polygon() only accepts integers greater than or \
equal to three as number of sides'			)
 elif length < 0:
  raise ValueError(
      'area_reg_polygon() only accepts non-negative values as \
length of a side'			)
 return (sides * length**2) / (4 * tan(pi / sides			))
 return (sides * length**2) / (4 * tan(pi / sides			))


if __name__ == "__main__":
 import doctest

 doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

 print('[DEMO] Areas of various geometric shapes: \n')
 print(f'''Rectangle: {area_rectangle(1_0, 2_0) = }''')
 print(f'''Square: {area_square(1_0) = }''')
 print(f'''Triangle: {area_triangle(1_0, 1_0) = }''')
 print(f'''Triangle: {area_triangle_three_sides(5, 1_2, 1_3) = }''')
 print(f'''Parallelogram: {area_parallelogram(1_0, 2_0) = }''')
 print(f'''Rhombus: {area_rhombus(1_0, 2_0) = }''')
 print(f'''Trapezium: {area_trapezium(1_0, 2_0, 3_0) = }''')
 print(f'''Circle: {area_circle(2_0) = }''')
 print(f'''Ellipse: {area_ellipse(1_0, 2_0) = }''')
 print('\nSurface Areas of various geometric shapes: \n')
 print(f'''Cube: {surface_area_cube(2_0) = }''')
 print(f'''Cuboid: {surface_area_cuboid(1_0, 2_0, 3_0) = }''')
 print(f'''Sphere: {surface_area_sphere(2_0) = }''')
 print(f'''Hemisphere: {surface_area_hemisphere(2_0) = }''')
 print(f'''Cone: {surface_area_cone(1_0, 2_0) = }''')
 print(f'''Conical Frustum: {surface_area_conical_frustum(1_0, 2_0, 3_0) = }''')
 print(f'''Cylinder: {surface_area_cylinder(1_0, 2_0) = }''')
 print(f'''Torus: {surface_area_torus(2_0, 1_0) = }''')
 print(f'''Equilateral Triangle: {area_reg_polygon(3, 1_0) = }''')
 print(f'''Square: {area_reg_polygon(4, 1_0) = }''')
 print(f'''Reqular Pentagon: {area_reg_polygon(5, 1_0) = }''')










'''simple docstring'''
from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload

class 						_lowerCamelCase					:




 '''simple docstring'''


 def __init__(      self      ,      __lowercase = None						):

  """simple docstring"""







  if components is None:
   __A  :		Optional[int]       =			[]
  __A  :		Dict       =			list(__lowercase						)


 def __len__(      self						):

  """simple docstring"""







  return len(self.__components						)


 def __str__(      self						):

  """simple docstring"""







  return "(" + ",".join(map(__lowercase      ,      self.__components						)						) + ")"


 def __add__(      self      ,      __lowercase						):

  """simple docstring"""







  __A  :		Union[str, Any]       =			len(self						)
  if size == len(__lowercase						):
   __A  :		Dict       =			[self.__components[i] + other.component(__lowercase						) for i in range(__lowercase						)]
   return Vector(__lowercase						)
  else:
   raise Exception('must have the same size'						)


 def __sub__(      self      ,      __lowercase						):

  """simple docstring"""







  __A  :		int       =			len(self						)
  if size == len(__lowercase						):
   __A  :		str       =			[self.__components[i] - other.component(__lowercase						) for i in range(__lowercase						)]
   return Vector(__lowercase						)
  else:  # error case
   raise Exception('must have the same size'						)


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      (float, int)						):
   __A  :		Dict       =			[c * other for c in self.__components]
   return Vector(__lowercase						)
  elif isinstance(__lowercase      ,      __lowercase						) and len(self						) == len(__lowercase						):
   __A  :		Optional[Any]       =			len(self						)
   __A  :		Optional[int]       =			[self.__components[i] * other.component(__lowercase						) for i in range(__lowercase						)]
   return sum(__lowercase						)
  else:  # error case
   raise Exception('invalid operand!'						)


 def  snake_case__   (      self						):

  """simple docstring"""







  return Vector(self.__components						)


 def  snake_case__   (      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      __lowercase						) and -len(self.__components						) <= i < len(self.__components						):
   return self.__components[i]
  else:
   raise Exception('index out of range'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  assert -len(self.__components						) <= pos < len(self.__components						)
  __A  :		str       =			value


 def  snake_case__   (      self						):

  """simple docstring"""







  if len(self.__components						) == 0:
   raise Exception('Vector is empty'						)
  __A  :		List[Any]       =			[c**2 for c in self.__components]
  return math.sqrt(sum(__lowercase						)						)







 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase = False						):

  """simple docstring"""







  __A  :		List[Any]       =			self * other
  __A  :		Any       =			self.euclidean_length() * other.euclidean_length()
  if deg:
   return math.degrees(math.acos(num / den						)						)
  else:
   return math.acos(num / den						)


def 			_lowercase       (				UpperCamelCase__       :					int			):
 assert isinstance(UpperCamelCase__,				UpperCamelCase__			)
 return Vector([0] * dimension			)


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 assert isinstance(UpperCamelCase__,				UpperCamelCase__			) and (isinstance(UpperCamelCase__,				UpperCamelCase__			))
 __A  :		List[str]       =			[0] * dimension
 __A  :		Tuple       =			1
 return Vector(UpperCamelCase__			)


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					Vector,				UpperCamelCase__       :					Vector			):
 assert (
     isinstance(UpperCamelCase__,				UpperCamelCase__			)
     and isinstance(UpperCamelCase__,				UpperCamelCase__			)
     and (isinstance(UpperCamelCase__,				(int, float)			))
 )
 return x * scalar + y


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 random.seed(UpperCamelCase__			)
 __A  :		Any       =			[random.randint(UpperCamelCase__,				UpperCamelCase__			) for _ in range(UpperCamelCase__			)]
 return Vector(UpperCamelCase__			)

class 						_lowerCamelCase					:




 '''simple docstring'''


 def __init__(      self      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  __A  :		str       =			matrix
  __A  :		str       =			w
  __A  :		Dict       =			h


 def __str__(      self						):

  """simple docstring"""







  __A  :		Tuple       =			''
  for i in range(self.__height						):
   ans += "|"
   for j in range(self.__width						):
    if j < self.__width - 1:
     ans += str(self.__matrix[i][j]						) + ","
    else:
     ans += str(self.__matrix[i][j]						) + "|\n"
  return ans


 def __add__(      self      ,      __lowercase						):

  """simple docstring"""







  if self.__width == other.width() and self.__height == other.height():
   __A  :		Union[str, Any]       =			[]
   for i in range(self.__height						):
    __A  :		List[Any]       =			[
        self.__matrix[i][j] + other.component(__lowercase      ,      __lowercase						)
        for j in range(self.__width						)
    ]
    matrix.append(__lowercase						)
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  else:
   raise Exception('matrix must have the same dimension!'						)


 def __sub__(      self      ,      __lowercase						):

  """simple docstring"""







  if self.__width == other.width() and self.__height == other.height():
   __A  :		Dict       =			[]
   for i in range(self.__height						):
    __A  :		str       =			[
        self.__matrix[i][j] - other.component(__lowercase      ,      __lowercase						)
        for j in range(self.__width						)
    ]
    matrix.append(__lowercase						)
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  else:
   raise Exception('matrices must have the same dimension!'						)


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      __lowercase						):  # matrix-vector
   if len(__lowercase						) == self.__width:
    __A  :		Tuple       =			zero_vector(self.__height						)
    for i in range(self.__height						):
     __A  :		Any       =			[
         self.__matrix[i][j] * other.component(__lowercase						)
         for j in range(self.__width						)
     ]
     ans.change_component(__lowercase      ,      sum(__lowercase						)						)
    return ans
   else:
    raise Exception(
        'vector must have the same size as the '
        'number of columns of the matrix!'						)
  elif isinstance(__lowercase      ,      (int, float)						):  # matrix-scalar
   __A  :		Optional[Any]       =			[
       [self.__matrix[i][j] * other for j in range(self.__width						)]
       for i in range(self.__height						)
   ]
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  return None


 def  snake_case__   (      self						):

  """simple docstring"""







  return self.__height


 def  snake_case__   (      self						):

  """simple docstring"""







  return self.__width


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if 0 <= x < self.__height and 0 <= y < self.__width:
   return self.__matrix[x][y]
  else:
   raise Exception('change_component: indices out of bounds'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if 0 <= x < self.__height and 0 <= y < self.__width:
   __A  :		Dict       =			value
  else:
   raise Exception('change_component: indices out of bounds'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  __A  :		Union[str, Any]       =			self.__matrix[:x] + self.__matrix[x + 1 :]
  for i in range(len(__lowercase						)						):
   __A  :		Dict       =			minor[i][:y] + minor[i][y + 1 :]
  return Matrix(__lowercase      ,      self.__width - 1      ,      self.__height - 1						).determinant()


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  if 0 <= x < self.__height and 0 <= y < self.__width:
   return (-1) ** (x + y) * self.minor(__lowercase      ,      __lowercase						)
  else:
   raise Exception('Indices out of bounds'						)







 def  snake_case__   (      self						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  if self.__height < 1:
   raise Exception('Matrix has no element'						)
  elif self.__height == 1:
   return self.__matrix[0][0]
  elif self.__height == 2:
   return (
       self.__matrix[0][0] * self.__matrix[1][1]
       - self.__matrix[0][1] * self.__matrix[1][0]
   )
  else:
   __A  :		List[str]       =			[
       self.__matrix[0][y] * self.cofactor(0      ,      __lowercase						) for y in range(self.__width						)
   ]
   return sum(__lowercase						)


def 			_lowercase       (				UpperCamelCase__       :					int			):
 __A  :		list[list[float]]       =			[[0] * n for _ in range(UpperCamelCase__			)]
 return Matrix(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 random.seed(UpperCamelCase__			)
 __A  :		list[list[float]]       =			[
     [random.randint(UpperCamelCase__,				UpperCamelCase__			) for _ in range(UpperCamelCase__			)] for _ in range(UpperCamelCase__			)
 ]
 return Matrix(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)






