Random Math Text Based Game - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Random Math Text Based Game (/thread-9304.html) |
Random Math Text Based Game - captainflint - Mar-31-2018 ı 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 ? RE: Random Math Text Based Game - captainflint - Apr-02-2018 [quote='capt RE: Random Math Text Based Game - ahsankhan - Aug-05-2018 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') |