def game_5(): cli.hello() print("Hello, " + cli.name + "!") print('Answer "yes" if given number is prime. Otherwise answer "no".') i = 0 steps = 3 while i < steps: number = randint(1, 3571) question = game5_logic(number) exam = "Question: {}" print(exam.format(str(number))) answer = prompt.string('Your answer: ') if logic.logic(answer, question) is None: return "Let's try again, " + cli.name + "!" i += 1 return 'Congratulations, ' + cli.name + '!'
def game_3(): cli.hello() print("Hello, " + cli.name + "!") print('Find the greatest common divisor of given numbers.') i = 0 steps = 3 while i < steps: random_number1_1 = randint(1, 100) random_number2_2 = randint(1, 100) question = game3_logic_1(random_number1_1, random_number2_2) exam = "Question: {} {}" print(exam.format(str(random_number1_1), str(random_number2_2))) answer = prompt.string('Your answer: ') if logic.logic(answer, question) is None: return "Let's try again, " + cli.name + "!" i += 1 return 'Congratulations, ' + cli.name + '!'
def game_1(): cli.hello() print("Hello, " + cli.name + "!") print('Answer "yes" if the number is even, otherwise answer "no".') i = 0 steps = 3 while i < steps: random_number = randint(1, 100) print('Question:', random_number) answer = prompt.string('Your answer: ') if random_number % 2 == 0: question = 'yes' elif random_number % 2 > 0: question = 'no' if logic.logic(answer, question) is None: return "Let's try again, " + cli.name + "!" i += 1 return 'Congratulations, ' + cli.name + '!'
def game_4(): cli.hello() print("Hello, " + cli.name + "!") print('What number is missing in the progression?') i = 0 steps = 3 while i < steps: start_prog = randint(1, 20) increase_prog = randint(1, 10) stop_prog = start_prog + (10 * increase_prog) shadow_number = randint(0, 9) prog = list(range(start_prog, stop_prog, increase_prog)) question = prog.pop(shadow_number) prog.insert(shadow_number, '..') exam = "Question: {}" print(exam.format(listToString(prog))) answer = prompt.string('Your answer: ') if logic.logic(answer, question) is None: return "Let's try again, " + cli.name + "!" i += 1 return 'Congratulations, ' + cli.name + '!'
def game_2(): cli.hello() print("Hello, " + cli.name + "!") print('What is the result of the expression?') i = 0 steps = 3 while i < steps: random_number1 = randint(1, 100) random_number2 = randint(1, 100) string = '*+-' char = choice(string) exam = "Question: {} {} {}" print(exam.format(str(random_number1), str(char), str(random_number2))) answer = prompt.string('Your answer: ') if char == '*': question = random_number1 * random_number2 elif char == '+': question = random_number1 + random_number2 elif char == '-': question = random_number1 - random_number2 if logic.logic(answer, question) is None: return "Let's try again, " + cli.name + "!" i += 1 return 'Congratulations, ' + cli.name + '!'