#calculator for a.b where . can be +,-,*,/,%
exp=raw_input("Enter expression a.b : ");
l=len(exp);
result=0;
x=int(exp[0]);
y=int(exp[2]);
if exp[1]=='+' :
result=x+y;
elif exp[1]=='-' :
result=x-y;
elif exp[1]=='*' :
result=x*y;
elif exp[1]=='/' :
result=x/y;
elif exp[1]=='%' :
result=x%y;
print "Result : ",result;
To Run : python cal.py
INPUT : 1+3
OUTPUT : 4
No comments:
Post a Comment