December 6th, 2012, 03:29 PM

Python Math Game Help Needed
I have to write a math game program and I have no clue where to start. The guidelines for the program are:
Welcome user to the game and ask if want to do addition or subtraction
If addition, generate random numbers between 0 and 6
If subtraction, generate random numbers between 0 and 9 and if the second number is larger than the first they need to be switched somehow.
For each game, generate 10 number facts, one at a time of the type chosen by the user.
User should be permitted to try each question twice and if they answer a question wrong both time, display the answer for them.
After answering the 10 facts, show the user how many answers they got right on the first try.
If they get all of them correct, display a special message to congratulate them
I need to do this by tomorrow and I do not know anyone that knows Python to ask. Any help will be greatly appreciated!
December 6th, 2012, 04:01 PM

Ask yourself:
Originally Posted by pschmidley
Welcome user to the game and ask if want to do addition or subtraction
"ask if"  How do you output the question and how do you get input from the user?
Originally Posted by pschmidley
If addition, generate random numbers between 0 and 6
"generate"  How do you get random numbers? How do you limit it to be between 0 and 6?
"numbers"  How many? Where can you store them all?
Originally Posted by pschmidley
If subtraction, generate random numbers between 0 and 9 and if the second number is larger than the first they need to be switched somehow.
"switched"  If there some easy way to switch two values? If not then what else could you do to ensure you print the larger value first?
Originally Posted by pschmidley
For each game, generate 10 number facts, one at a time of the type chosen by the user.
"10"  Besides copying and pasting code (the wrong answer), how else can you repeat something 10 times?
Originally Posted by pschmidley
User should be permitted to try each question twice and if they answer a question wrong both time, display the answer for them.
"try each question twice"  What's the best way to ask a second time only if they got the answer wrong the first time?
"answer a question wrong"  When did you calculate the answer?
Originally Posted by pschmidley
After answering the 10 facts, show the user how many answers they got right on the first try.
"how many answers"  How will you keep track of this?
Spoiler: I don't know Python.
December 6th, 2012, 09:39 PM

Swap is kind of fun in python. matlab and j can work similarly.
Code:
if minuend < subtrahend:
(minuend, subtrahend,) = (subtrahend, minuend,)
(Swap was fun on the IBM 360, maybe it was an earlier computer. The machine code swap executed
a^=b;b^=a;a^=b
)
Last edited by b49P23TIvg; December 6th, 2012 at 09:42 PM.
[code]
Code tags[/code] are essential for python code and Makefiles!