Example #1
0
def checkEqual(a, b):
    if a == b:
        io.printTTS('Correct')
        return True
    else:
        io.printTTS('Wrong')
        return False
Example #2
0
def compareNum(n1, n2):
    io.printTTS("Compare numbers")
    io.printTTS("{} || {} ".format(n1, n2))
    io.printTTS("Which side has greater number, left or right or same?")
    ans = io.readLine()
    if (ans == 'same' and n1 == n2) or (ans == 'left' and n1 > n2) or (ans == 'right' and n1 < n2):
        io.printTTS('Correct')
    else:
        io.printTTS('Wrong')
Example #3
0
def compareItems(a, b, item):
    io.printTTS("Count {}".format(item))
    print(emoji.emojize((':'+item+': ') *a) + ' | ' + emoji.emojize((':'+item+': ') *b))
    io.printTTS('Do the left-side and right-side has same number of {}? Please input y for yes, n for no'.format(item))
    ans = io.readChar()
    while ans not in ['n', 'N', 'y', 'Y']:
        print("You can only input 'n' or 'y'")
        ans = io.readChar()
    if (ans in ['y', 'Y'] and a == b):
        print(emoji.emojize(':thumbs_up: ')*3 + "You got it. Both left and right sides have {} {}".format(a,item))
    elif (ans in ['n', 'N'] and a != b):
        print(emoji.emojize(':thumbs_up: ')*3 + "You got it. Left side has {} {}, but right side has {} {}".format(a,item, b,item))
    else:
        print(emoji.emojize(':thumbs_down: ')*3 + "Wrong. Left side has %d %s, but right side has {} {}".format(a,item, b,item))
Example #4
0
def AddupNum(m, n, n1):
    io.printTTS("Add up numbers")
    io.printTTS("Joy has {} {}".format(n1, m))
    pitem.emojiPrint(m, n1)
    io.printTTS("How many more {}s Joy need to buy so she will have {} {}s?".format(m, n, m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n - n1)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n - n1)
    
    io.printTTS("So we know that {} = {} + {}".format(n, n1, n - n1))
Example #5
0
def writeNum(m, n):
    io.printTTS("Write number from {} to {}".format(m, n))
    for i in range(m, n+1):
        io.printTTS('Write {} in number:'.format(inflect.engine().number_to_words(i)))
        while 1:
            try:
                ans = int(sys.stdin.readline()[:-1])
            except ValueError:
                io.printTTS("input again:")
                continue
            break
            
        if ans == i:
            io.printTTS('Correct')
        else:
            io.printTTS('Wrong')
Example #6
0
def subtractTest(a, b):
    io.printTTS("Calculate a - b")
    io.printTTS("{} - {} = ".format(a, b))
    ans = io.readInt()
    while ans != (a - b):
        io.printTTS(emoji.emojize(':thumbs_down: :thumbs_down: :thumbs_down: '), "Wrong! Please calculate the value again")
        ans = io.readInt()

    io.printTTS(emoji.emojize(':thumbs_up: :thumbs_up: :thumbs_up: ') + "You got it. The correct answer is {}".format(ans))
Example #7
0
def addTest(a, b):
    io.printTTS("Calculate a + b")
    io.printTTS("{} + {} = ".format(a, b))
    ans = io.readInt()
    while ans != (a + b):
        io.printTTS("Wrong! Please calculate the value again")
        ans = io.readInt()

    io.printTTS("You got it. The correct answer is {}".format(ans))
Example #8
0
def countObjects(m, n):
    io.printTTS("Count objects")
    pitem.emojiPrint(m, n)
    io.printTTS("How many {} do you see?".format(m))

    ans = io.readInt()
    if ans == n:
        io.printTTS('Correct')
    else:
        io.printTTS('Wrong')
Example #9
0
def countInShapes(m, n, s):
    io.printTTS("Count objects in {}".format(s))
    pitem.emojiPrint(m, n)
    io.printTTS("How many {} do you see?".format(m))

    ans = io.readInt()
    if ans == n:
        io.printTTS('Correct')
    else:
        io.printTTS('Wrong')
Example #10
0
def compareObjects(m, n1, n2):
    io.printTTS("Compare number of objects")
    print(emoji.emojize(':{}: '.format(m) * n1 + ' | ' + ':{}: '.format(m) * n2))
    io.printTTS("Which side has more {}, left or right or same?".format(m))

    ans = io.readLine()
    if (ans == 'same' and n1 == n2) or (ans == 'left' and n1 > n2) or (ans == 'right' and n1 < n2):
        io.printTTS('Correct')
    else:
        io.printTTS('Wrong')
Example #11
0
def decomposeNumBaseTen(n):
    io.printTTS("Subtract 10")
    io.printTTS("{} - 10 = ".format(n))

    ans = io.readInt()
    res = ca.checkEqual(ans, n - 10)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        res = ca.checkEqual(ans, n - 10)

    io.printTTS("So we know that {} = {} - {}".format(n - 10, n, 10))
Example #12
0
def composeNumBaseTen(n):
    io.printTTS("Add numbers based on 10")
    io.printTTS("10 + {} = ".format(n))

    ans = io.readInt()
    res = ca.checkEqual(ans, n + 10)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        res = ca.checkEqual(ans, n + 10)

    io.printTTS("So we know that {} = {} + {}".format(10 + n, 10, n))
Example #13
0
def chooseGrade():
    gradeList = [str(i) for i in range(1, 9)]
    gradeList = ['k'] + gradeList
    while 1:
        io.printTTS('Please choose the Grade of the student:')

        io.printTTS("    k for Kindergarten")
        io.printTTS("    [1-8] for Grade 1 to 8")
        grade = io.readChar()
        if grade in gradeList:
            return grade
        else:
            io.printTTS(
                "Only Grade {} is currently supported".format(gradeList))
            continue
Example #14
0
def countNumfromX(x, y):
    io.printTTS("Count from {} to {}, leave a blank between numbers".format(
        x, y))
    ans = sys.stdin.readline()
    ans = ans.split()
    ans = map(int, ans)
    if ans == range(x, y + 1):
        io.printTTS(emoji.emojize(':thumbs_up: ') * 3 + "You got it.")
    else:
        io.printTTS(
            emoji.emojize(':thumbs_down: ') * 3 + "The correct sequence is:")
        print([i for i in range(x, y + 1)])
Example #15
0
def IdentifyShape(s):
    io.printTTS("Identify shapes")

    if s in twoDShapes:
        fig = pitem.plot2D(s)
    if s in threeDShapes:
        fig = pitem.plot3D(s)
    plt.draw()
    plt.pause(0.5)
    plt.close()

    io.printTTS("What is the shape in the picture?")
    print("hints:")
    print(twoDShapes)
    print(threeDShapes)
    ans = io.readLine()
    res = ca.checkEqual(ans, s)
    while not res:
        io.printTTS("Double check")
        ans = io.readLine()
        res = ca.checkEqual(ans, s)
Example #16
0
def main():
    if settings.guiflag:
        GUI.KidsMath().mainloop()
        sys.exit(1)

    print(">>>> Welcome to KidsMath, Enjoy! <<<<")

    grade = chooseGrade()
    k = TestCases(grade)
    while not k:
        io.printTTS("Selected Grade {} has not been implemented yet".format(k))
        grade = chooseGrade()
        k = TestCases(grade)

    object_methods = [
        method_name for method_name in dir(k)
        if callable(getattr(k, method_name))
    ]
    object_methods = CTR.RemoveSysMethods(object_methods)

    io.printTTS("There are totally {} test cases implemented".format(
        len(object_methods)))

    io.printTTS("Please specify how many tests you want try:")
    testcnt = io.readInt()

    RandomMethodList = []
    for i in range(testcnt):
        secure_random = random.SystemRandom()
        m = secure_random.choice(object_methods)
        RandomMethodList.append(m)
        object_methods.remove(m)

    print(RandomMethodList)
    # recursively call all the test cases
    for name in RandomMethodList:
        getattr(k, name)()
Example #17
0
def Number2Name(a):
    io.printTTS('Spell {} in Characters:'.format(a))
    line = io.readLine()
    p = inflect.engine()
    CA.checkEqual(line, p.number_to_words(a))
Example #18
0
def CompareWeight(n1, n2):
    io.printTTS("Compare weight of objects")
    io.printTTS("Bob is {} pounds".format(n1))
    pitem.emojiPrint('sheep', 1)
    io.printTTS("Joy is {} pounds".format(n2))
    pitem.emojiPrint('pig2', 1)

    io.printTTS("Who is heavier, Joy or Bob?")
    ans = io.readLine()
    res = ca.checkEqual(ans, 'Joy')
    while not res:
        io.printTTS("Double check")
        ans = io.readLine()
        res = ca.checkEqual(ans, 'Joy')
    io.printTTS("So we know that {} pounds is heavier than {} pounds".format(
        n2, n1))

    io.printTTS("Who is lighter, Joy or Bob?")
    ans = io.readLine()
    res = ca.checkEqual(ans, 'Bob')
    while not res:
        io.printTTS("Double check")
        ans = io.readLine()
        res = ca.checkEqual(ans, 'Bob')

    io.printTTS("So we know that {} pounds is lighter than {} pounds".format(
        n1, n2))
Example #19
0
def ClassifyCount(m1, n1, m2, n2, m3, n3):
    l = [m1] * n1 + [m2] * n2 + [m3] * n3
    r = random.SystemRandom()
    r.shuffle(l)
    pitem.emojiPrintList(l)

    io.printTTS("How many {} do you see?".format(m1))
    ans = io.readInt()
    res = ca.checkEqual(ans, n1)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        res = ca.checkEqual(ans, n1)

    io.printTTS("How many {} do you see?".format(m2))
    ans = io.readInt()
    res = ca.checkEqual(ans, n2)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        res = ca.checkEqual(ans, n2)

    io.printTTS("How many {} do you see?".format(m3))
    ans = io.readInt()
    res = ca.checkEqual(ans, n3)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        res = ca.checkEqual(ans, n3)
Example #20
0
def AddObjects(m, n1, n2):
    io.printTTS("Add objects")
    io.printTTS("Bob has {} {}".format(n1, m))
    pitem.emojiPrint(m, n1)
    io.printTTS("Joy has {} {}".format(n2, m))
    pitem.emojiPrint(m, n2)
    io.printTTS("How many {} do they have in total?".format(m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n1 + n2)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n1 + n2)

    io.printTTS("So we know that {} + {} = {}".format(n1, n2, n1 + n2))
Example #21
0
def TestCases(g):
    if g == 'k':
        return TestCasesK()
    elif g == '1':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '2':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '3':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '4':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '5':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '6':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '7':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    elif g == '8':
        io.printTTS("Grade {} Test Cases have not been created yet".format(g))
        return
    else:
        io.printTTS("Invalid Grade {}".format(g))
        return
Example #22
0
def DecomposeNum(m, n, n1):
    io.printTTS("Decompose numbers")
    io.printTTS("We have {} {}".format(n, m))
    pitem.emojiPrint(m, n)
    io.printTTS("We give Joy {} {}".format(n1, m))
    pitem.emojiPrint(m, n1)
    io.printTTS("How many {} are left?".format(m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n - n1)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n - n1)

    io.printTTS("So we know that {} - {} = {}".format(n, n1, n - n1))
Example #23
0
def SubObjects(m, n1, n2):
    io.printTTS("Subtract objects")
    io.printTTS("Bob has {} {}".format(n1, m))
    pitem.emojiPrint(m, n1)
    io.printTTS("Joy takes away {} {} from Bob".format(n2, m))
    pitem.emojiPrint(m, n2)
    io.printTTS("How many {} does Bob have now?".format(m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n1 - n2)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n1 - n2)

    io.printTTS("So we know that {} - {} = {}".format(n1, n2, n1 - n2))
Example #24
0
def quitProgram():
    io.printTTS("Press ")
    i = input()
    if i == 'q':
        sys.exit()
Example #25
0
def countNumby10s(m, t):
    io.printTTS("Count from 10 up to {} by 10 s".format(m))
    
    # if t == 1, randomly skip a number 
    if t:
        t = (int)(random.SystemRandom().choice(string.digits)) * 10
        
    for i in range(10, m+1, 10):
        if i == t:
            continue
        io.printTTS(str(i))
        # wait for 1 second
        time.sleep(1)

    io.printTTS('Is there any number missing in this sequence? Say yes or no')
    ans = io.readLine()
    if ans not in ['yes', 'no']:
        io.printTTS('Is there any number missing in this sequence? Please input from keyboard: y for yes, n for no')
        ans = io.readChar()
   
    while ans not in ['yes', 'no', 'y', 'n']:
        io.printTTS('Please input from keyboard: y for yes, n for no')
        ans = io.readChar()

    if (ans in ['yes', 'y'] and t):
        io.printTTS(emoji.emojize(':thumbs_up: ')*3 + "You got it. {} is missing".format(t))
    elif (ans in ['no', 'n'] and not t):
        io.printTTS(emoji.emojize(':thumbs_up: ')*3 + "You got it. All numbers are there")
    else:
        if ans in ['yes', 'y']: 
            io.printTTS(emoji.emojize(':thumbs_down: ')*3 + "Wrong. You say there is some number missing, but actually all numbers are in the sequence")
        if ans in ['no', 'n']: 
            io.printTTS(emoji.emojize(':thumbs_down: ')*3 + "Wrong. You say there is no number missing, but actually {} is NOT in the sequence".format(t))
Example #26
0
def guessValue(a):
    io.printTTS("Guess value in range 100")

    while 1:
        try:
            line = io.readInt()
        except KeyboardInterrupt:
            break
    
        if not line:
            break
    
        if line < a:
            io.printTTS("Guessed value is too small")
            io.printTTS("Guess the value again:")
            continue
        if line > a:
            io.printTTS("Guessed value is too big")
            io.printTTS("Guess the value again:")
            continue
    
        io.printTTS("You got it, the value is {}".format(a))
        break
Example #27
0
def decomposeObjBaseTen(m, n):
    io.printTTS("Take 10 objects away")
    io.printTTS("Bob has {} {}s".format(n, m))
    pitem.emojiPrint(m, n)
    io.printTTS("Joy takes 10 {}s away".format(m))
    pitem.emojiPrint(m, 10)
    io.printTTS("How many {}s does Bob have now?".format(m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n - 10)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n - 10)

    io.printTTS("So we know that {} = {} - {}".format(n - 10, n, 10))
Example #28
0
def composeObjBaseTen(m, n):
    io.printTTS("Add objects based on 10")
    io.printTTS("Bob has 10 {}s".format(m))
    pitem.emojiPrint(m, 10)
    io.printTTS("Joy gives Bob {} more {}s".format(n, m))
    pitem.emojiPrint(m, n)
    io.printTTS("How many {}s does Bob have now?".format(m))

    ans = io.readInt()
    pitem.emojiPrint(m, ans)
    res = ca.checkEqual(ans, n + 10)
    while not res:
        io.printTTS("Double check")
        ans = io.readInt()
        pitem.emojiPrint(m, ans)
        res = ca.checkEqual(ans, n + 10)

    io.printTTS("So we know that {} = {} + {}".format(10 + n, 10, n))