user1 = int(input("Choose a number: "))
user2 = int(input("Choose another number: "))
op = input("Choose an operation to be preformed on these numbers (add, subtract, multiply): ")
def add():
user3 = user1 + user2
print str(user1) + " + " + str(user2) + " = " + str(user3)
def sub():
user3 = user1 - user2
print str(user1) + " - " + str(user2) + " = " + str(user3)
def times():
user3 = user1 * user2
print str(user1) + " * " + str(user2) + " = " + str(user3)
if op == "add":
add()
elif op == "subtract":
sub()
elif op == "multiply":
times()
else:
print "that is an invalid answer!"
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter