Calculator Using Python

0

 # copy this code and past it in what you use to code python

def calculator():

    num1 = (input("please enter the first number: "))

    operation = input("please enter an operation (+-*/): ")

    num2 = (input("please enter the second number: "))


    num1 = int(num1)

    num2 = int(num2)




    if operation == "+":

        print(num1+num2)


    elif operation == "-":

        print(num1-num2)


    elif operation == "*":

        print(num1*num2)


    elif operation == "/":

        print(num1/num2)


    else:

        print("error you have enter an unkwon operation")


    def re_run():

        re_run1 = input("Do you want to re run it?: ")

        if re_run1.lower() == "yes":

            calculator()

        elif re_run1.lower() == "no":

            print("okay")

            quit()

        else:

            print("Invalid option")

            re_run()

    re_run()


calculator() 



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.