Skip to content

Commit 36cc0c1

Browse files
committed
all changes 9-th step of project
1 parent e8a1296 commit 36cc0c1

File tree

11 files changed

+29
-4
lines changed

11 files changed

+29
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
demo.cast
33
gcd.cast
44
on_README.cast
5-
prog.cast
5+
prog.cast
6+
prime.cast

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ brain-calc: https://asciinema.org/a/daDnWV3XC3pNoNAFgOneXFrU7
99

1010
brain-gdc: https://asciinema.org/a/o4wK1dzQaefQiUzAt2QBRbVBQ
1111

12-
brain-progression: https://asciinema.org/a/sKFhvVykjbhLLwAzoAsbudPlz
12+
brain-progression: https://asciinema.org/a/sKFhvVykjbhLLwAzoAsbudPlz
13+
14+
brain-prime: https://asciinema.org/a/25XdP6wecFzqghXUhuQ65c9dV
691 Bytes
Binary file not shown.
486 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import brain_games.scripts.games.sample
2+
3+
4+
def main():
5+
cond_answer = 'Answer "yes" if given number is prime. Otherwise answer "no".'
6+
print(brain_games.scripts.games.sample.samples('brain-prime', cond_answer))
7+
8+
9+
if __name__ == '__main__':
10+
main()

brain_games/scripts/games/sample.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ def typo_brain_progression(first_num):
4949
return replace_num
5050

5151

52+
def typo_brain_prime(num):
53+
re = []
54+
for i in range(1, num + 1):
55+
if num % i == 0:
56+
re.append(i)
57+
print(f'Question: {num}')
58+
return 'yes' if len(re) == 2 else 'no'
59+
60+
5261
def samples(type_game, condition_answer):
5362
print('Welcome to the Brain Games!')
5463
name = prompt.string('May I have your name? ')
@@ -69,6 +78,8 @@ def samples(type_game, condition_answer):
6978
correct_answer = type_brain_gcd(first_number, second_number)
7079
case 'brain-progression':
7180
correct_answer = typo_brain_progression(first_number)
81+
case 'brain-prime':
82+
correct_answer = typo_brain_prime(first_number)
7283
answer = input('Your answer: ')
7384
if answer == str(correct_answer):
7485
number_of_successful_attempts += 1
-4.95 KB
Binary file not shown.

dist/hexlet_code-0.5.2.tar.gz

-6.2 KB
Binary file not shown.
5.38 KB
Binary file not shown.

dist/hexlet_code-0.5.3.tar.gz

6.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)