python program to compute the result when two number and one operator are given by user


Write a program in python to compute the result when two number and one operator are given by user 

n1=int(input("Enter 1st number : "))

n2=int(input("Enter 2nd number : "))

op=input("Enter the Operator +,-,*,/ : ")

if op=='+' :

    print("The Result is : ",n1+n2)

elif op=='-' :

    print("The Result is : ",n1-n2)

elif op=='*' :

print("The Result is : ",n1*n2)

elif op=='/':

print("The Result is : ",n1/n2)

else:

print("Wrong Operator Entered")


output : 

Enter 1st number : 5

Enter 2nd number : 4

Enter the Operator +,-,*,/ : *

The Result is :  20

Post a Comment

0 Comments