diff options
Diffstat (limited to 'dev/pacmath.activity/questionGenerator.py')
-rw-r--r-- | dev/pacmath.activity/questionGenerator.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/dev/pacmath.activity/questionGenerator.py b/dev/pacmath.activity/questionGenerator.py index b62453d..c95dac5 100644 --- a/dev/pacmath.activity/questionGenerator.py +++ b/dev/pacmath.activity/questionGenerator.py @@ -23,6 +23,8 @@ class questionGenerator: self.minOp = minOp self.maxOp = maxOp self.operation = operation + + print operation def getQuestion(self): """ @@ -31,21 +33,20 @@ class questionGenerator: @return A tuple contining two strings: ("question", "answer") """ op1 = randint(self.minOp, self.maxOp) - op2 = randint(self.minOp, self.maxOp) - - if( self.operation == 'x' or self.operation == '*' or self.operation == 'X' ): + op2 = randint(self.minOp, self.maxOp) + + if( self.operation == ['x'] ): answer = op1*op2 return (str(op1)+" x " + str(op2) + " = ?", str(answer)) - elif( self.operation == '+' ): + if( self.operation == ['+'] ): answer = op1+op2 return (str(op1)+" + "+ str(op2) + " = ?", str(answer)) - elif( self.operation == '-' ): + elif( self.operation == ['-'] ): answer = op1-op2 return (str(op1)+" - "+ str(op2) + " = ?", str(answer)) - elif( self.operation == '/' ): + elif( self.operation == ['/'] ): answer = op1*op2 return (str(answer)+" / "+ str(op1) + " = ?", str(op2)) - else: return null def getQuestionSet(self): |