このコードを実行すると、2 番目の定義で問題が発生します。* de *f 乗算 (): 構文エラーを受け取ると、def の de が歌われます。
import random
def start () :
print "Welcome!"
choose ()
def choose () :
choice = input """would you like to
add, subtract, or multiply?
1 2 3
"""
if choice = 1 :
add ()
if choice = 2 :
subtract ()
if choice = 3 :
multiply ()
def multiply () :
x = random.random ()
x = round ()
y = random.random ()
y = round ()
print "What is the answer to: ", x,"*", y, " ?"
answer = input ": "
z = x*y
if answer == z :
print "you are correct!"
elif answer < z :
print "your answer is low! The correct answer was ", z
elif answer > z :
print "your answer is high! The correct answer was ", z
multiply ()
def add () :
x = random.random ()
x = round ()
y = random.random ()
y = round ()
print "What is the answer to: ", x,"+", y, " ?"
answer = input ": "
z = x+y
if answer == z :
print "you are correct!"
elif answer < z :
print "your answer is low! The correct answer was ", z
elif answer > z :
print "your answer is high! The correct answer was ", z
def subtract () :
x = random.random ()
x = round ()
y = random.random ()
y = round ()
print "What is the answer to: ", x,"*", y, " ?"
answer = input ": "
z = x*y
if answer == z :
print "you are correct!"
elif answer < z :
print "your answer is low! The correct answer was ", z
elif answer > z :
print "your answer is high! The correct answer was ", z