Calculator Program in Python

Sharing is caring!

In this blog post, I will share how to make the Calculator program in Python. I hope You will get your perfect solution in this blog post. Now describing below how to make Calculator Program in Python.

Calculator Program in Python

def add(x,y):

    return x+y

def subtract(x,y):

    returnx-y

    def multiply(x,y):

        return x*y

    def add(x,y):

        returnx/y

        print(“Select operation.”)

        print(“1.Add”)

        print(“2.Subtract”)

        print(“3.Multiply”)

        print(“Divid&”)

        choice= input(“Enter choice(1/2/3/4)”)

        numi= int(input(“Enter fast number:”))

        num2= int(input(“Enter second number”))

        if choice ==’1′:

            print(numl,”+”,num2,”=”,add(numl,num2))

          

        elif choice ==’2′:

                print(numl,”-“,num2,”=”,subtract(numl,num2))

        elif choice ==’3′:

                    print(numl,”***”,num2,”=”,multiply(numl,num2))

        elif choice ==’4′:

                        print(num-1,”/”,num2,”=”,divide(numl,num2))

        else:

                          print(“You press Invalid input”)

               

Output:

Select operation.

  1. Add
  2. Subtract
  3. Multiply
  4. Divide

Enter choice(1/2/3/4):3

Enter the fast number: 35

Enter second number: 3

35*3 = 150

Output Proved:

Calculator Program in Python

Leave a Comment