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()
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.º 3
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 input_str_non_empty(msg):
    string = ""
    while len(string) == 0:
        string = input(msg)
        if len(string) == 0:
            clean_screen()
    return string
Exemplo n.º 5
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)}")
Exemplo n.º 6
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 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.º 9
0
 def selection_movement(self):
     print("NEW MOVEMENT")
     options = ["Deposit", "Retirement"]
     s = ''
     i = 0
     while s != 's':
         clean_screen()
         print(options[i].upper())
         s = input("[s] To select\n_").lower()
         if s == 's':
             continue
         if i == len(options) - 1:
             i = 0
         else:
             i += 1
     return options[i]
 def __init__(self, opcs, exit_val, welcome=False, still=True):
     """
         Constructor of the class Menu
         Params:
             opcs => a list of tuples that contains the value of the opc,
             the title and the function
             welcome => a tag for the first time the proyect boots
             exit_val => the value that ends the program or returns
     """
     clean_screen()
     if welcome == True:
         self.print_welcome()
     self.__posible_options = opcs
     self.__exit_val = exit_val
     self.__welcome = welcome
     self.__still = still
    def show_report(self):
        clean_screen()
        subtotal = 0
        taxes = 0
        total = 0

        print("TICKET")
        print(f"Client Name: {self.client_name}")
        print_table_row(["Article", "Amount", "Unitary Price", "Total"])
        for article in self.articles:
            print_table_row([article.description, article.amount,
                             article.unitary_price, article.get_total()])
            subtotal += article.get_total()
        taxes = 0.15 * subtotal
        total = subtotal + taxes
        print_table_row(["", "", "Subtotal:", subtotal])
        print_table_row(["", "", "Taxes 15%:", taxes])
        print_table_row(["", "",  "Total:", round(total, 3)])
Exemplo n.º 12
0
def selection_opt(options, msg):
    selected = ''
    i = 0
    while selected != 's':
        clean_screen()
        print(msg)
        print(options[i])
        selected = input("[s] to select one option\n_ ")

        if selected == 's':
            continue

        if i == len(options) - 1:
            i = 0
        else:
            i += 1

    return options[i]
Exemplo n.º 13
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.º 14
0
def selection_client():
    """
        Function to select the client to add transaction
    """
    s = ""
    if len(clients) == 1:
        return clients[0]

    i = 0
    while s.lower() != "s":
        clean_screen()
        print(clients[i].name)
        s = input("[s] to select the user\n_")
        if s.lower() == "s":
            continue
        if i == len(clients) - 1:
            i = 0
        else:
            i += 1

    return clients[i]
Exemplo n.º 15
0
 def show_transactions_report(self):
     clean_screen()
     print(f"""
                                             Acount Status
           Name: {self.owner_name}
           Initial Salary: $ {self.initial_salary}
     """)
     print_table_row(["Movement", "Deposit", "Retirement", "Salary"])
     total_deposit = 0
     total_retiremts = 0
     for i in range(len(self.movements)):
         if self.movements[i][0] > 0:
             print_table_row([i + 1, f"$ {self.movements[i][0]}",
                              "", f"$ {self.movements[i][1]}"])
             total_deposit += self.movements[i][0]
         else:
             print_table_row(
                 [i + 1, "", f"$ {abs(self.movements[i][0])}", f"$ {self.movements[i][1]}"])
             total_retiremts += abs(self.movements[i][0])
     print_table_row(["Total", f"$ {total_deposit}",
                      f"$ {total_retiremts}", f"$ {self.salary}"])
 def eval_opc(self):
     """
         This option evals every option and in base of the current opc it
         excute a function of the opc.
     """
     for item in self.__posible_options:
         if self.__opc == self.__exit_val:
             # option if opc is equal to exit val
             self.exit()
             return 0
         elif item[0] == self.__opc:
             # executing the opc funct
             clean_screen()
             if self.__still == True:
                 self.still(item[2])
             else:
                 item[2]()
                 input("_")
             return 0
     print("WOUPS! select a posible option.")
     input()
Exemplo n.º 17
0
    def new_movement(self):
        ready = ''
        while ready != 'r':
            clean_screen()
            option = self.selection_movement()

            clean_screen()
            print(option.upper())
            amount = round(input_float(
                f"Give me the amount to {option}: ", min_val=20, default=20), 2)
            round(amount, 3)
            if option.lower() == 'deposit':
                self.salary += amount
                self.movements.append((amount, self.salary))
                print(f"Deposit of $ {amount}")
            else:
                if self.salary - amount > 0:
                    self.salary -= amount
                    self.movements.append((-1 * amount, self.salary))
                    print(f"Retirement of $ {amount}")
                else:
                    print("Ups! Invalid Transaction not enough money")
            input("_")

            clean_screen()
            print(f"Salary: $ {self.salary}")
            ready = input(
                "[r] To exit and print the report\n[Enter] For new Transaction\n_")

        self.show_transactions_report()
Exemplo n.º 18
0
 def print_list(list_s):
     clean_screen()
     if(len(list_s) == 0):
         print("No results with the filter")
     for student in list_s:
         print(f'{student.name} | {student.sex} | {student.hair_color} | {student.eye_color} | {student.weight} kg. | {student.height} mts.')
Exemplo n.º 19
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")
 def draw():
     clean_screen()
     for column in m:
         for item in column:
             print(f"| {item} |", end="")
         print()