擅长:python、mysql、java
<pre><code># Define the main function
def main():
num1 = randomNumbers()
num2 = randomNumbers()
print "Please add the following numbers:"
print " ", num1
print "+ ", num2
print " "
correctAnswer = num1 + num2
userAnswer = int(raw_input(" "))
if userAnswer == correctAnswer:
print "Great job!"
else:
# Return the correct answer for the user
print "You're wrong! The correct answer was %s!" % correctAnswer
# Define a function to generate random numbers
def randomNumbers():
import random # Imports the random module
# Generates two random numbers to be added
number = random.randrange(100,1000)
return number
# Call the main function
main()
</code></pre>