Beispiel #1
0
def start(game):
    greeting = 'Welcome to the Brain Games!'
    print(greeting)
    print(game.DESCRIPTION)
    print('')
    name = get_user_name()

    counter = 0
    while counter < 3:
        question, correct_answer = game.start_round()

        if type(correct_answer) == int:
            answer = integer(question)
        else:
            answer = string(question)

        if answer != correct_answer:
            print(f'Your answer: {answer}')
            print(f"'{answer}' is wrong answer ;(."
                  f" Correct answer was '{correct_answer}'")
            print(f"Let's try again, {name}!")
            break
        print(f'Your answer: {answer}')
        print('Correct!')
        counter += 1

    if counter == 3:
        print(f'Congratulations, {name}!')
def main():
    print("""
Welcome to the Brain Games!
What number is missing in the progression?\n""")
    user_name = cli.get_user_name()
    attempts = ATTEMPTS
    while attempts > 0:
        progression, answer = make_progression()
        print("Question: {}".format(progression))
        user_answer = cli.get_user_answer()
        engine.run(user_answer, answer, user_name)
        attempts -= 1
Beispiel #3
0
def main():
    print("""
Welcome to the Brain Games!
Answer "yes" if number even otherwise answer "no"\n""")
    user_name = cli.get_user_name()
    attempts = ATTEMPTS
    while attempts > 0:
        questions = engine.get_random_number()
        answer = get_correct_answer(questions)
        print("Question: {}".format(questions))
        user_answer = cli.get_user_answer()
        engine.run(user_answer, answer, user_name)
        attempts -= 1
Beispiel #4
0
def run(game):
    print('Welcome to the Brain Games!\n'
          f'{game.TASK}\n')
    name = get_user_name()
    for _ in range(ROUNDS):
        question, true_answer = game.get_round()
        print(f'Question: {question}')
        answer = get_user_answer()
        if answer != true_answer:
            print(f'{answer} is wrong answer ;(. Correct answer'
                  f' was {true_answer}.\n' f'Let\'s try again, {name}!\n')
            return
        print('Correct!\n')
    print(f'Congratulations, {name}!\n')
Beispiel #5
0
def main():
    print("""
Welcome to the Brain Games!
Find the greatest common divisor of given numbers.\n""")
    user_name = cli.get_user_name()
    attempts = ATTEMPTS
    while attempts > 0:
        number_first = engine.get_random_number()
        number_second = engine.get_random_number()
        answer = str(gcd(number_first, number_second))
        print("Question: {} {}".format(number_first, number_second))
        user_answer = cli.get_user_answer()
        engine.run(user_answer, answer, user_name)
        attempts -= 1
def main():
    print("""
Welcome to the Brain Games!
What is the result of the expression?\n""")
    user_name = cli.get_user_name()
    attempts = ATTEMPTS
    while attempts > 0:
        num_first = engine.get_random_number()
        num_second = engine.get_random_number()
        operation = operation_list[randint(0, len(operation_list) - 1)]
        answer = get_correct_answer(num_first, num_second, operation)
        print("Question: {} {} {}".format(num_first, operation, num_second))
        user_answer = cli.get_user_answer()
        engine.run(answer, user_answer, user_name)
        attempts -= 1
Beispiel #7
0
def main():
    print("""
Welcome to the Brain Games!
Answer "yes" if given number is prime. Otherwise answer "no".\n""")
    user_name = cli.get_user_name()
    attempts = ATTEMPTS
    while attempts > 0:
        number_prime = engine.get_random_number()
        if check_prime_number(number_prime) is False:
            answer = 'no'
        else:
            answer = 'yes'
        print("Questions: {}".format(number_prime))
        user_answer = cli.get_user_answer()
        engine.run(user_answer, answer, user_name)
        attempts -= 1
Beispiel #8
0
def play(game):
    greet()

    print_text(game.RULES)

    user_name = get_user_name()

    answer_count = 0
    while answer_count < ROUNDS_COUNT:
        question, answer = game.get_question()
        print_question(question)
        user_answer = get_user_answer()
        if user_answer != answer:
            print_fail_answer(user_answer, answer, user_name)
            return
        print_text(RIGHT_ANSWER_TEXT)
        answer_count += 1
    congratulate(user_name)
Beispiel #9
0
def run(game):
    cli.welcome_game(game.MESSAGE)
    user_name = cli.get_user_name()
    cli.welcome_user(user_name)

    counter = 0
    while counter < ROUNDS_COUNT:
        question, answer = game.round()

        cli.print_question(question)
        player_answer = cli.get_player_answer()

        if answer != player_answer:
            cli.incorrect_answer(answer, player_answer, user_name)
            return

        cli.correct_answer()
        counter += 1

    cli.print_congratulation(user_name)
Beispiel #10
0
def main():
    get_user_name()
def main():
    """Start of programm."""
    cli.welcome_user()
    cli.get_user_name()
def welcome_user() -> str:
    """Ask user name and print greeting."""
    user_name = get_user_name()
    greeting = f'Hello, {user_name}!'
    print(greeting)
    return user_name
Beispiel #13
0
def main():
    print('Welcome to the Brain Games!\n')
    get_user_name()