-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
112 additions
and
231 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import prompt | ||
|
||
|
||
def welcome_user(): | ||
print('Welcome to the Brain Games!') | ||
global name | ||
name = prompt.string('May I have your name? ') | ||
print(f'Hello, {name}!') | ||
|
||
|
||
def engine(brain_game): | ||
count_correct_answers = 0 | ||
while count_correct_answers < 3: | ||
correct_answer = brain_game() | ||
user_answer = prompt.string('Your answer: ') | ||
if user_answer == correct_answer: | ||
print('Correct!') | ||
count_correct_answers += 1 | ||
else: | ||
print(f"'{user_answer}' is wrong answer ;(." | ||
f" Correct answer was '{correct_answer}'.") | ||
print(f"Let's try again, {name}!") | ||
break | ||
if count_correct_answers == 3: | ||
print(f"Congratulations, {name}!") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from random import randint, choice | ||
|
||
|
||
def game_calc(): | ||
print('What is the result of the expression?') | ||
first_random_number = randint(1, 20) | ||
second_random_number = randint(1, 20) | ||
random_operation = choice('+-*') | ||
if random_operation == '+': | ||
correct_answer = str(first_random_number + second_random_number) | ||
elif random_operation == '-': | ||
correct_answer = str(first_random_number - second_random_number) | ||
elif random_operation == '*': | ||
correct_answer = str(first_random_number * second_random_number) | ||
print(f'Question: {first_random_number} {random_operation} {second_random_number}') | ||
return correct_answer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from random import randint | ||
|
||
|
||
def game_even(): | ||
print('Answer "yes" if the number is even, otherwise answer "no".') | ||
random_number = randint(1, 100) | ||
correct_answer = ('yes', 'no')[random_number % 2] | ||
print(f'Question: {random_number}') | ||
return correct_answer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from random import randint | ||
|
||
|
||
def game_gcd(): | ||
print('Find the greatest common divisor of given numbers.') | ||
first_random_number = randint(1, 100) | ||
second_random_number = randint(1, 100) | ||
correct_answer = 1 | ||
for i in range(2, min(first_random_number, second_random_number) + 1): | ||
if first_random_number % i == 0 and second_random_number % i == 0: | ||
correct_answer = i | ||
print(f'Question: {first_random_number} {second_random_number}') | ||
return str(correct_answer) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from random import randint | ||
|
||
|
||
def game_prime(): | ||
print('Answer "yes" if given number is prime. Otherwise answer "no".') | ||
random_number = randint(3, 100) | ||
correct_answer = 'yes' | ||
for i in range(2, random_number): | ||
if random_number % i == 0: | ||
correct_answer = 'no' | ||
break | ||
print(f'Question: {random_number}') | ||
return correct_answer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from random import randint | ||
|
||
|
||
def game_progression(): | ||
print('What number is missing in the progression?') | ||
random_start_number = randint(1, 20) | ||
random_step = randint(1, 10) | ||
random_sequence = [] | ||
for i in range(10): | ||
random_sequence.append(random_start_number + random_step * i) | ||
random_index_of_seq = randint(0, 9) | ||
correct_answer = str(random_sequence[random_index_of_seq]) | ||
random_sequence[random_index_of_seq] = '..' | ||
print('Question:', *random_sequence) | ||
return correct_answer | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-2.17 KB
(24%)
brain_games/scripts/__pycache__/brain_progression.cpython-311.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.