Simple Calculator Program in Python Language


#Make a simple Calculator in python

#Function addition the two numbers

def addition(a,b):
return a+b

# Function Subtract the two numbers

def subtract(a,b): 
return a-b

#Function Multiply the two numbers

def multiply(a,b): 
 return a*b

#Function Divides two numbers

def divide(a,b): 
return a/b 

#function module the two numbers

def module(a,b): 
return(a%b)
 
print("Select operation.") 
 
 print("1 addition") 
 print("2 subtract") 
 print("3 multiply") 
 print("4 divide") 
 print("5 module") 

 # Take the input 

 choice=input("Enter choice(1/2/3/4/5):")  
 
num1=float(input("Enter the first number:")) 

num2=float(input("Enter the Second number:")) 

if choice =='1': 
 print(num1,"+",num2,"=", addition(num1,num2))

elif choice == '2': 
 print(num1, "-", num2,"=", subtract(num1,num2))

elif choice == '3': 
 print(num1, "*", num2,"=", multiply(num1,num2))

elif choice == '4': 
 print(num1, "/", num2,"=", divide(num1,num2))

elif choice == '5': 
 print(num1, "%", num2, "=", module(num1,num2))

else: print("Invaild input")


OutPut:




Output :

Select operation.
1 addition
2 subtract
3 multiply
4 divide
5 module
Enter choice(1/2/3/4/5): 3
Enter the first number:4
Enter the Second number:2
4.0 * 2.0 = 8.0