Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64737

Re: Help with my 8-year old son's first program. I'm stuck!

Newsgroups comp.lang.python
Date 2014-01-25 02:32 -0800
References <453f851d-815d-4bdd-b591-71cafc95084f@googlegroups.com>
Message-ID <5dce8685-9d73-4519-99e4-d79d62fd0bf4@googlegroups.com> (permalink)
Subject Re: Help with my 8-year old son's first program. I'm stuck!
From justinpmullins@gmail.com

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with my 8-year old son's first program. I'm stuck! justinpmullins@gmail.com - 2014-01-25 02:02 -0800
  Re: Help with my 8-year old son's first program. I'm stuck! Ervin Hegedüs <airween@gmail.com> - 2014-01-25 11:24 +0100
  Re: Help with my 8-year old son's first program. I'm stuck! justinpmullins@gmail.com - 2014-01-25 02:32 -0800
  Re: Help with my 8-year old son's first program. I'm stuck! Peter Otten <__peter__@web.de> - 2014-01-25 11:41 +0100
    Re: Help with my 8-year old son's first program. I'm stuck! justinpmullins@gmail.com - 2014-01-25 07:58 -0800
  Re: Help with my 8-year old son's first program. I'm stuck! Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-25 11:35 +0000

csiph-web