lundi 16 mars 2015

Python Calculator, No Answer

I am very much interested in Python and I decided to learn it. I covered many things but I am stuck when try to make a Calculator in which we just need to type the numbers and the operation type


For Example- 10 ^ 2


The thing that happens is I get no answer. And i use Command Prompt for the output.


My Code looks like this:



# Calculator



print " "
print " Calculator "
print " "

num = int(raw_input(">> ")).split()

num1 = int(num[0])

op = num[1]

num2 = int(num[2])

if (op=='+'):

print ">>>", num1 + num2
elif (op=='-'):

print ">>>", num1 - num2
elif (op=='*'):

print ">>>", num1 * num2
elif (op=='/'):

print ">>>", num1 / num2
elif (op=='^'):

print ">>>", pow(num1,num2)
elif (op=='%'):

print ">>>", num1 % num2


I use Python 2.7.


Please Help Me For The Same.


Aucun commentaire:

Enregistrer un commentaire