Python Forum
Random Math Text Based Game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Math Text Based Game
#1
ı 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 ?
Reply
#2
[quote='capt
Reply
#3
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  beginner having text based adventure trouble mrgee 2 2,032 Dec-16-2021, 05:07 AM
Last Post: buran
  Help - random number/letter guessing game juin22 1 3,152 Aug-16-2020, 06:36 AM
Last Post: DPaul
  Word based Game of 21 DatNerdKid 2 65,903 Aug-24-2018, 03:25 PM
Last Post: DuaneJack
  Text Based Tic Tac Toe incineratez 3 4,394 Nov-19-2017, 10:47 AM
Last Post: heiner55
  trying to get my random number guessing game to work! NEED HELP RaZrInSaNiTy 4 6,733 Oct-06-2016, 12:49 AM
Last Post: tinabina22

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020