Tuesday, 15 June 2010

class - Python Calculator, No Answer -


I am very interested in Python and I have decided to know it. I have covered many things but I am stuck trying to make a calculator in which we need to type the number and type of operation

For example - 10 ^ 2

Whatever happens, I do not get any answer. And I use the command prompt for output.

My code looks like this:

  # calculator print "" print "calculator" print "" number = int (raw_input ("> gt; & gt;") ). Partition () num1 = int (num [0]) op = num [1] num2 = int (num [2]) if (op == '+'): printed "> gt; gt; & gt; Num1 + num2 elif (op == '-'): print ""> gt1 - num2 elif (op == '*'): Print "Gt1 / num2 elif (op == ' ^ '): "Print" and gt; & gt; " Gt1 * num2 elif (op == '/'): print ">>>>"; Pow (num1, num2) elif (op == '%'): print "& gt;  

I use Python 2.7

Please help me for that

inserted you int , that is

  num = raw_input ( "& Gt; & gt;") .split () Remove the #int cast  

The output will be:

  & gt; & Gt; 10 ^ 2> and gt; & Gt; 100  

No comments:

Post a Comment