diff --git a/Day 10/art.py b/Day 10/art.py new file mode 100644 index 0000000..51de36a --- /dev/null +++ b/Day 10/art.py @@ -0,0 +1,16 @@ +logo = """ + _____________________ +| _________________ | +| | Pythonista 0. | | .----------------. .----------------. .----------------. .----------------. +| |_________________| | | .--------------. || .--------------. || .--------------. || .--------------. | +| ___ ___ ___ ___ | | | ______ | || | __ | || | _____ | || | ______ | | +| | 7 | 8 | 9 | | + | | | | .' ___ | | || | / \ | || | |_ _| | || | .' ___ | | | +| |___|___|___| |___| | | | / .' \_| | || | / /\ \ | || | | | | || | / .' \_| | | +| | 4 | 5 | 6 | | - | | | | | | | || | / ____ \ | || | | | _ | || | | | | | +| |___|___|___| |___| | | | \ `.___.'\ | || | _/ / \ \_ | || | _| |__/ | | || | \ `.___.'\ | | +| | 1 | 2 | 3 | | x | | | | `._____.' | || ||____| |____|| || | |________| | || | `._____.' | | +| |___|___|___| |___| | | | | || | | || | | || | | | +| | . | 0 | = | | / | | | '--------------' || '--------------' || '--------------' || '--------------' | +| |___|___|___| |___| | '----------------' '----------------' '----------------' '----------------' +|_____________________| +""" diff --git a/Day 10/main.py b/Day 10/main.py new file mode 100644 index 0000000..2bdd8fc --- /dev/null +++ b/Day 10/main.py @@ -0,0 +1,48 @@ +from art import logo + +#Calculator + +# Add +def add(n1, n2): + return n1 + n2 + +# Subtract +def subtract(n1, n2): + return n1 - n2 + +# Multiply +def multiply(n1, n2): + return n1 * n2 + +# Divide +def divide(n1, n2): + return n1 / n2 + +# Calculator dict +operations = { + "+": add, + "-": subtract, + "*": multiply, + "/": divide, +} + +def calculator(): + print(logo) + num1 = float(input("What's the first number?: ")) + num2 = float(input("What's the second number?: ")) + for symbol in operations: + print(symbol) + operation_symbol = input("Pick an operation: ") + answer = operations[operation_symbol](num1, num2) + print(f"{num1} {operation_symbol} {num2} = {answer}") + check = input(f"Type 'y' to continue calculating with {answer}, or type 'n' to exit.: ") + + while check == "y": + operation_symbol = input("Pick another operation: ") + old_num = answer + num3 = float(input("What's the next number?: ")) + answer = operations[operation_symbol](answer, num3) + print(f"{old_num} {operation_symbol} {num3} = {answer}") + check = input(f"Type 'y' to continue calculating with {answer}, or type 'n' to exit.: ") + calculator() +calculator() \ No newline at end of file