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

justinpmullins at gmail.com justinpmullins at gmail.com
Sat Jan 25 05:02:15 EST 2014


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




More information about the Python-list mailing list