def mainprime(): """Do something interesting. # noqa: DAR101 username """ welcome_user() print('Answer "yes" if given number is prime. Otherwise answer "no".') username = welcome_user1() good = 0 while good < 3: number = randomnumber() if number >= 2: index = 2 res = 'yes' while index < number: if abs(number) % index == 0: res = 'no' index = number else: index += 1 else: res = 'no' answer = question(number) if answer == res: goodanswer() good += 1 else: wrong_answer(username, answer, res) finish_game(username)
def mainprogression(): """Do something interesting. # noqa: DAR101 username """ welcome_user() print('What number is missing in the progression?') username = welcome_user1() good = 0 while good < 3: startprog = randomnumber() stepprog = random.randint(1, 10) stopprog = startprog + stepprog * 10 prog = (list(range(startprog, stopprog, stepprog))) index = random.randint(0, 9) minusnumber = prog[index] prog[index] = '..' number = 0 prog1 = '' while number < 10: prog1 = '{} {} '.format(prog1, str(prog[number])) number += 1 answer = question(('{}'.format(prog1))) if answer == str(minusnumber): goodanswer() good += 1 else: wrong_answer(username, answer, minusnumber) finish_game(username)
def maincalc(): """Do something interesting. # noqa: DAR101 username """ welcome_user() print('What is the result of the expression?') username = welcome_user1() good = 0 while good < 3: number1 = randomnumber() number2 = randomsymbol() number3 = randomnumber() if number2 == '*': number = number1 * number3 else: number = number1 + number3 answer = question(('{} {} {}'.format(number1, number2, number3))) if answer == str(number): goodanswer() good += 1 else: wrong_answer(username, answer, number) finish_game(username)
def maingcd(): """Do something interesting. # noqa: DAR101 username """ welcome_user() print('Find the greatest common divisor of given numbers.') username = welcome_user1() good = 0 while good < 3: number1 = randomnumber() number2 = randomnumber() first = number1 second = number2 while first != 0 and second != 0: if first > second: first %= second else: second %= first gcd = first + second answer = question(('{} {}'.format(number1, number2))) if answer == str(gcd): goodanswer() good += 1 else: wrong_answer(username, answer, gcd) finish_game(username)
def maineven(): """Do something interesting. # noqa: DAR101 username """ welcome_user() print('Answer "yes" if number even otherwise answer "no".') username = welcome_user1() good = 0 while good < 3: task = randomnumber() answer = question(task) if (task % 2 == 0 and answer == 'yes') or (task % 2 == 1 and answer == 'no'): goodanswer() good += 1 elif task % 2 == 0: wrong_answer(username, answer, 'yes') else: wrong_answer(username, answer, 'no') finish_game(username)