Menu driven Python program for basic arithmetic operations

print("Enter A :")
a = int(input())
print("\nEnter B :")
b = int(input())
print("\nChoose Options To Perform : ")
print("\n1.Addition")
print("\n2.Subtraction")
print("\n3.Multiplication")
print("\n4.Division")
print("\n\nEnter Your Choice :")
choice = int(input())
if choice==1 :
	print("\nAddition of A + B is : ",a+b)
elif choice==2 :
	print("\nSubtraction of A - B is : ",a-b)
elif choice==3 :	
	print("\nMultiplication of A * B is : ",a*b)
elif choice==4 :
	if(b == 0) :
		print("b cannot be 0(Zero) for Division operation")
	else :		
		print("\nDivision of A / B is : ",a/b)
else :
	print("Invalid Choice")

Output :
Enter A :20

Enter B :30

Choose Options To Perform :
1.Addition :
2.Subtraction :
3.Multiplication :
4.Division :

Choice is : 1

Addition of A + B is : 50



Leave a comment