Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Calculator Using Python

 # 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() 





This post first appeared on Site Of, please read the originial post: here

Share the post

Calculator Using Python

×

Subscribe to Site Of

Get updates delivered right to your inbox!

Thank you for your subscription

×