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))
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))
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')
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')
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)
def Number2Name(a): io.printTTS('Spell {} in Characters:'.format(a)) line = io.readLine() p = inflect.engine() CA.checkEqual(line, p.number_to_words(a))