Calculate website

def calculator(): while True: # take input from the user num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) operator = input("Enter operator (+, -, *, /): ") # perform the calculation based on operator if operator == '+': result = num1 + num2 elif operator == '-': result = num1 - num2 elif operator == '*': result = num1 * num2 elif operator == '/': result = num1 / num2 else: print("Invalid operator. Try again.") continue # print the result print("Result: ", result) # ask user if they want to do another calculation again = input("Do you want to do another calculation? (y/n)") if again.lower() != 'y': break # run the calculator calculator()

Comments

Popular posts from this blog

Hosting list

BEST BROKERS FOR TRADING IN 2023

Crypto exchange Binance