def flatFiguresMenu() -> NoReturn: ''' This function displays the list of math figures options and select the choice. ''' header() print('Áreas das figuras planas'.center(66)) print(""" [1] Área de um quadrado, retângulo ou paralelogramo [2] Área de um triangulo [3] Área de um trapézio [4] Área de um lozango [5] Área de um círculo """) escolha = input('➤ ') selectFunction = { '1': lambda: squareAreaMenu(), '2': lambda: triangleAreaMenu(), '3': lambda: trapezeAreaMenu(), '4': lambda: diamondAreaMenu(), '5': lambda: circleAreaMenu(), } selectFunction[escolha]()
def circleAreaMenu() -> NoReturn: ''' Shows header and options to calculate the area of the circle. ''' header() print('A =π.r²\n') radius = float(input('Raio [r] ➤ ')) print(f'\nArea [A] = {circleArea(pi, radius)}')
def trapezeAreaMenu() -> NoReturn: ''' Shows header and options for calculating the area of the trapeze. ''' header() print('A=((B+b).h)/2\n') largerBase = float(input('Base Maior [B] ➤ ')) smallerBase = float(input('Base Menor [b] ➤ ')) height = float(input('Altura [h] ➤ ')) print(f'\nÁrea [A] = {trapezeArea(largerBase, smallerBase, height)}')
def diamondAreaMenu() -> NoReturn: ''' Shows header and options for calculating the area of the diamond. ''' header() print('A=(D.d)/2\n') largerDiagonal = float(input('Diagonal Maior [D] ➤ ')) smallerDiagonal = float(input('Diagonal Menor [d] ➤ ')) print(f'\nArea [A] = {diamondArea(largerDiagonal, smallerDiagonal)}')
def menuAreaBH() -> NoReturn: ''' Shows header and options for calculating the area of the trangle based on the base and height.\n ''' header() print("A = (B.h)/2\n") base = float(input('Base [B] ➤ ')) height = float(input('Altura [h] ➤ ')) result = float(calculateTriangleAreaBH(base, height)) print(f'\nÁrea [A] = {result}')
def squareAreaMenu() -> NoReturn: ''' This function get the base size and the heigth size, calculate this values, and displays the result. ''' header() print("A=B.h\n") base = float(input('Base [B] ➤ ')) height = float(input('Altura [h] ➤ ')) result = float(calculateSquareArea(base, height)) print(f'\nÁrea [A] = {result}')
def menuAreaSP() -> NoReturn: ''' Shows header and options for calculating the area of triangle based on the sides of triangle.\n ''' header() print("p=(a+b+c)/2") print("A = √(p.(p-a).(p-b).(p-c))\n") sideA = float(input('Lado A ➤ ')) sideB = float(input('Lado B ➤ ')) sideC = float(input('Lado C ➤ ')) result = calculateTriangleAreaSP(sideA, sideB, sideC) print(f'\nÁrea [A] = {result}')
def triangleAreaMenu() -> NoReturn: ''' Shows header and options for calculating the area of the triangle based on two methods: base and height, and sizes. ''' header() print('Triangulo'.center(66)) print(""" [1] Calcular com os valores da base e da altura A = (B.h)/2 [2] Calcular com os valores dos lados do triangul p=(a+b+c)/2 A = √(p.(p-a).(p-b).(p-c)) \n""") choice = input('➤ ') if choice == '1': menuAreaBH() elif choice == '2': menuAreaSP()