Python Forum

Full Version: Random Math Text Based Game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ı have math game which have random questions. In level 1 ı have one problem is limited.(only level 1 + operator). İf user correct answer he gain one stars. At 5 stars the game will end. I 'll Show you official problem;

"Question is If the player’s answer is an integer but the answer is wrong the message that will show up is shown
below, the number of the stars collected by the player will be showed as follows and so will the
next question and the stars the player has under the question and above the input"

Wrong! You do not gain any stars for that question!
You now have 0 out of five stars!
What is 5 + 0?




print "Welcome to the random math question game!"

print ("Level 1")
print ("Possible length of Numbers: 1")
print ("Possible number of Operators: 1")
import random
import operator

ops = ['+', '-', '*', '/']


num1 = random.randint(0,10)
num2 = random.randint(0,10)
operation1 = ops[0]


print("What is {} {} {}?\n".format(num1,operation1,num2))
useranswer=raw_input(">>> ")
how ı do it ?
[quote='capt
print ("Welcome to the random math question game!")
 
print ("Level 1")
print ("Possible length of Numbers: 1")
print ("Possible number of Operators: 1")
import random
import operator
 
num1 = random.randint(0,10)
num2 = random.randint(0,10)
a=num1+num2
print("What is {} {}?\n".format(num1,num2))

useranswer=input()
h=int(useranswer)
if h==a:
    print('congratulation')
else:
    print('wrong')