A simple calculator program using functions using Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support.

Program Listing

# Simple Calculator Using Functions in Python
# Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.blogspot.com and www.jakerpomperada.com
# jakerpomperada@gmail.com
# Barangay Mandalagan, Bacolod City, Negros Occidental Philippines

# This function adds two numbers
def add(x, y):
    return x + y

# This function subtracts two numbers
def subtract(x, y):
    return x - y

# This function multiplies two numbers
def multiply(x, y):
    return x * y

# This function divides two numbers
def divide(x, y):
    return x / y

choice = input("What mathematical operation do you want to use [+,-,*,/]? ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice in ('+', '-', '*', '/'):

        if choice == '+':
            print("The sum of " ,num1, " and ", num2, " is  :", add(num1, num2))

        elif choice == '-':
            print("The difference between " ,num1, " and ", num2, " is  : ", subtract(num1, num2))

        elif choice == '*':
            print("The product between " ,num1, " and ", num2, " is  : ", multiply(num1, num2))

        elif choice == '/':
            print("The quotient of " ,num1, " and ", num2, " is  : ", divide(num1, num2))

Leave a Reply

Your email address will not be published.