Exemplo n.º 1
0
def menu():
    #    exp_n = [[3, 1, 17], [4, 13, -2], [1, -6 , -3]] #this should give you -772
    #    r = det(exp_n)
    #    print(r)
    RETURN_VAL = 4
    opc = 0

    while opc != RETURN_VAL:
        print("""
                DETERMINANT MATRIX
                1- A determinat of a matrix order 1 to 5 manually
                2- A determinat of a random matrix
                3- Show documentation.
                4- Go back
              """)
        opc = input_int("_")
        if opc == 1:
            size = input_int("Size of the matrix:",
                             allow_negative=False,
                             default=2,
                             min_val=2,
                             max_val=5)
            m = create_matrix(size)
            m_numpy = np.array(m)
            print_matrix(m)
            r = det(m)
            r_numpy = np.linalg.det(m_numpy)
            print(f"|m| = {r}")
            print(f"Resultado de numpy: {r_numpy}")
            input("Enter to continue")
            clean_screen()
        if opc == 2:
            size = input_int("Size of the random matrix: ",
                             min_val=2,
                             max_val=15,
                             allow_negative=False,
                             default=2)
            m = gen_random_matrix(size)
            m_numpy = np.array(m)
            print_matrix(m)
            r_numpy = np.linalg.det(m_numpy)
            r = det(m)
            print(f"|m| = {r}")
            print(f"Resultado de numpy: {r_numpy}")
            input("Enter to continue")
            clean_screen()
        if opc == 3:
            help(print_matrix)
            help(det)
            help(transf_signs_rows)
            help(reduce_matrix)
            clean_screen()
        if opc == 4:
            input("returning to main menu")
            clean_screen()
        else:
            clean_screen()
def main():
    """
        Main function Handler
    """
    clean_screen()
    row = input_int("Row of the digit to search: ", False)
    column = input_int("Column of the digit to search: ", False, max_val=row)
    r = pascal(row, column)  # 6
    draw_triangle(row)
    print(f"the digit in position [{row},{column}] is {r}")
def triangle_area():
    """ Calculate and prints the area of a triangle"""
    print_title("OPTION 1-TRIANGLE AREA")
    h = input_int("Triangle height: ")
    b = input_int("Triangle base: ")
    precision = input("Do you want Decimals?: [y/n]")
    if precision == "y":
        r = (b * h) / 2
    else:
        r = (b * h) // 2
    print(f"AREA: {r}")
Exemplo n.º 4
0
    def handle_add():
        desc = input_str_non_empty("Article Description: ")
        amount = input_int("Article Amount: ", False, min_val=1, default=1)
        ex_factor = round(input_float("Article Factor Cost: ", False), 2)
        base_cost = input_int("Article base cost: ",
                              False,
                              min_val=1,
                              default=1)

        article = Article(desc, amount, ex_factor, base_cost)
        r.add_article(article)
def menu():
    EXIT_VAL = 4
    alumnos_del_profe_valdo = []
    opc = 0

    while opc != EXIT_VAL:
        print("MENU")
        print("1. Altas Alumnos")
        print("2. Reporte de Alumnos")
        print("3. Random Matrix List")
        print("4. Salir")
        opc = int(input_int("_"))
        if opc == 1:
            new_student = input("Name of the new student:\n")
            alumnos_del_profe_valdo.append(new_student)
            clean_screen()
        elif opc == 2:
            print("Alumnos:")
            for alum in alumnos_del_profe_valdo:
                print(alum)
            input("Enter to continue")
            clean_screen()
        elif opc == 3:
            random_matrix_list()
            input("Enter to continue")
            clean_screen()
        elif opc == EXIT_VAL:
            print("byeee.......")
            clean_screen()
        else:
            print("opc invalid")
            input("Enter to continue")
            clean_screen()
Exemplo n.º 6
0
def handle_add_ticket():
    """
        Function that handles to add a ticket.
    """
    if len(clients) == 0:
        print("No clients register for the moment, Cant do transactions.")
        print("Please, Add a client")
        return 0

    client = selection_client()

    t = Ticket(client.name)

    still = True

    while still:
        clean_screen()
        print(f"Client: {client.name}")
        print("Adding New Article")
        print("*" * 20)
        desc = input_str_non_empty("Description Article: ")
        amount = input_int("Amount: ", False, min_val=1, default=1)
        price = round(
            input_float("Price per product: ", False, min_val=1, default=1), 2)
        new_article = Article(desc, amount, price)
        t.add_article(new_article)

        still = still_bool("More Products? [y/n]: ")
    t.show_report()
def main():
    print("CYCLODE FUNCTION - OPTION 7")
    print("*" * 20)
    print("Advice: Not allowing negative numbers")
    r = input_int("Circle Radius:\n", allow_negative=False)
    n_p = input_int("Until which PI value you wanna graph:\n",
                    allow_negative=False)
    n_t = input_int("How many PI values for generating teta angles:\n",
                    allow_negative=False)
    val = 0
    teta_angle = []
    for n in range(n_t):
        while val < n_p * math.pi:
            val += 1 / n_t * math.pi
            teta_angle.append(val)
    cycloid_function(r, teta_angle=teta_angle)
def main():
    """
        Main function that handles the excersice 4.
    """
    client_name = input("Client Name: ")

    t = Ticket(client_name)
    still = True

    while still:
        clean_screen()
        print(f"""
                        Client: {client_name}
              """)
        print("Adding New Article")
        print("*" * 20)
        desc = input_str_non_empty("Description Article: ")
        amount = input_int("Amount: ", False, min_val=1, default=1)
        price = round(input_float("Price per product: ",
                                  False, min_val=1, default=1), 2)
        new_article = Article(desc, amount, price)
        t.add_article(new_article)

        still = still_bool("More Products? [y/n]: ")

    t.show_report()
Exemplo n.º 9
0
def main():
    """
        Main Handler function
    """
    clean_screen()
    num = input_int("Give me a Integer number to sum digits: ",
                    allow_negative=False)
    print(f"Num: {num}\n Sum Digits: {sum_digits(num)}")
def cuadratic_ecuations():
    """ Calculates x1, x2  in a cuadratic equation"""

    print_title("OPTION 2-CUADRATIC SOLUTIONS")
    a = input_int("Insert a number A in ecuation: ")
    b = input_int("Insert a number B in ecuation: ")
    c = input_int("Insert a number C in ecuation: ")
    try:
        x1 = (-b + sqrt(b**2 - 4 * a * c)) / (2 * a)
        x2 = (-b - sqrt(b**2 - 4 * a * c)) / (2 * a)
    except ValueError:
        x1 = (-b + sqrt(abs(b**2 - 4 * a * c))) / (2 * a)
        x2 = (-b - sqrt(abs(b**2 - 4 * a * c))) / (2 * a)
        return print(f"x1: {x1}i\nx2:{x2}i")
    except ZeroDivisionError:
        return print("We cant dive into 0.")
    print(f"x1: {x1}\nx2:{x2}")
Exemplo n.º 11
0
 def add_trip(self):
     print(f"Elevator Trip {len(self.trip_amount_persons) + 1}")
     amount = input_int("Amount of people in the elevator trip: ",
                        allow_negative=False)
     weight = round(
         input_float("Weight in the elevator trip: ", allow_negative=False),
         2)
     self.trip_amount_persons.append(amount)
     self.trip_weight.append(weight)
     print("Elevator Trip registered")
Exemplo n.º 12
0
def create_matrix(size):
    """ Input for creating a matrix """
    m = []
    for i in range(size):
        m.append([])
        for j in range(size):
            n = input_int(f"Value row {i + 1} column {j + 1}: ",
                          min_val=-99,
                          max_val=99,
                          default=0)
            m[i].append(n)
    return m
    def print_opc(self):
        """
            This function prints all the posible options in the menu plus the
            exit val.

        """
        clean_screen()
        print("OPTIONS| PLEASE SELECT ONE")
        for item in self.__posible_options:
            print_format_item(item[0], item[1])
        print_format_item(self.__exit_val,
                          f"{ 'Exit' if self.__welcome else 'Back' }")
        print("=" * 40)
        return input_int("_")
Exemplo n.º 14
0
    def student_form(self):
        name = input_str_non_empty("Student Name: ")
        age = input_int("Student age: ", allow_negative=False,
                        min_val=3, default=3)
        sex = selection_opt(OPTION_SEX, "Student gender: ")
        height = input_float("Student Height: ",
                             allow_negative=False, min_val=1, default=1)
        weight = input_float("Student Weight: ",
                             allow_negative=False, min_val=1, default=1)
        eye_color = selection_opt(OPTION_EYE_COLOR, "Student Eye color: ")
        hair_color = selection_opt(OPTION_HAIR_COLOR, "Student hair color: ")

        newStudent = Student(name, sex, age, height,
                             weight, eye_color, hair_color)
        return newStudent
Exemplo n.º 15
0
def main():
    clean_screen()
    n = input_int("Give me a num: ")
    r_iterative = iterative_sum(n)
    r_recursion = recursive_sum(n)

    @cronometer
    def conatiner_fibo(n):
        print(f"Fibo with memo: {fibonacci(n)}")

    @cronometer
    def container_fibo_slow(n):
        print(f"Fibo SLOOOOW: {fibonacci_slow(n)}")

    conatiner_fibo(n)
    container_fibo_slow(n)
    print(f"factorial: {factorial(n)}")
    print(f"recursion: {r_recursion}")
    print(f"iterative: {r_iterative}")
Exemplo n.º 16
0
def main_menu():
    """ Main menu function program"""
    clean_screen()
    opc = 0
    while opc != EXIT_VALUE:
        print(""" 
        MAIN MENU
        ***************************************
        1. Triangle Area
        2. Solution Cuadratic Equations 
        3. Average of n Grades 
        4. Higher value of n Numbers
        5. Higher value of random Numbers
        6. Parametric Functions - Vector Calculation
        7. Cycloid Funcitions - Vector Calculation
        8. Custom Error - Warning crash the program
        9. Custom Error managed - Exception catched
        10. Determinat Matrix
        11. Random Higher Numbers
        12. Sesion 4 Clase
        13. Pascal Algorithm
        14. Cronometer test
        15. Fibonacci Recursion and Factorial Recursion
        16. Sum the digits of a string 
        17. EXIT
        """)

        # Input
        opc = input_int("_")

        # Main Options
        if opc == 1:
            triangle_area()
            opc = still()
        elif opc == 2:
            cuadratic_ecuations()
            opc = still()
        elif opc == 3:
            average_grades()
            opc = still()
        elif opc == 4:
            max_number()
            opc = still()
        elif opc == 5:
            print_title("OPTION 5 - Higher num of random numbers")
            size = input_int("Tamano de la lista: ")
            max_random_num(size)
            opc = still()
        elif opc == 6:
            parametric_fun()
            opc = still()
        elif opc == 7:
            cyclode_function()
            opc = still()
        elif opc == 8:
            run_custom_exception()
            # this exeception ends program
        elif opc == 9:
            run_manage_custom_exception()
            opc = still()
        elif opc == 10:
            determinat_menu()
            opc = still()
        elif opc == 11:
            s = input_int("Size of the random list: ",
                          allow_negative=False,
                          min_val=3,
                          default=2)
            random_higher_num(s)
            opc = still()
        elif opc == 12:
            sesion4()
            opc = still()
        elif opc == 13:
            pascal()
            opc = still()
        elif opc == 14:
            cronometer_test()
            opc = still()
        elif opc == 15:
            recursion()
            opc = still()
        elif opc == 16:
            sum_digits()
            opc = still()
        elif opc == EXIT_VALUE:
            exit()
        else:
            print("Option No valid Check de menu")