PS: At the first statement, we've also tried 
 
op == "d":

But that doesn't work either.



On Saturday, January 25, 2014 10:02:15 AM UTC, justinp...@gmail.com wrote:
> My son is learning Python and I know nothing about computers. 
> 
> He's written a simple calculator program that doesn't work. For the life of 
> me, I can't see why.
> 
> Any help gratefully received. Here's his code: 
> 
> def a():
> 
>       import sys
> 
>       print("welcome to the calculation")
> 
>       print("please type a number")
> 
>       one = int(sys.stdin.readline())
> 
>       print("type d for division,")
> 
>       print("type m for multiplication,") 
> 
>       print("type s for subtraction,")
> 
>       print("and type p for plus")
> 
>       op = (sys.stdin.readline())
> 
>       print("%s selected" % op)
> 
>       print("please enter another number")
> 
>       two = int(sys.stdin.readline())
> 
>       if op == str(d):
> 
>               out == one / two
> 
>               print("the answer is %s" % out)
> 
>       elif op == "m":
> 
>               out == one * two
> 
>               print("the answer is %s" % out)
> 
>       elif op == "s":
> 
>               out == one - two
> 
>               print("the answer is %s" % out)
> 
>       elif op == "p":
> 
>               out == one + two
> 
>               print("the answer is %s" % out)
> 
>       else:
> 
>               print("huh")
> 
> 
> 
> Where is he going wrong?
> 
> Many thanks in advance
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to