Skip to content

Commit d520473

Browse files
touch brain_prime.py and prime.py
1 parent ce50577 commit d520473

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ The first project on [Hexlet](https://ru.hexlet.io/professions/python/projects/4
2121

2222
[![asciicast](https://asciinema.org/a/kSeWIg1XFAvI37egtMgaKHNqK.svg)](https://asciinema.org/a/kSeWIg1XFAvI37egtMgaKHNqK)
2323

24+
### THE FIFTH GAME: brain-prime
25+
26+
[![asciicast](https://asciinema.org/a/zIBoTjFRs9zhiKysSPEI6u2ya.svg)](https://asciinema.org/a/zIBoTjFRs9zhiKysSPEI6u2ya)

brain_games/game_skeleton.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def game_start(game):
1515
answer = get_answer(question)
1616

1717
if answer != correct:
18-
print(f"{answer} is wrong answer ;(. Correct answer was {correct}."
18+
print(f"'{answer}' is wrong answer ;(. Correct answer was '{correct}'."
1919
f"\nLet's try again, {player}!")
2020
return
2121
print('Correct')

brain_games/games/prime.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from random import randint
2+
3+
RULES = 'Answer "yes" if given number is prime. Otherwise answer "no".'
4+
5+
def start_game():
6+
num = randint(1, 100)
7+
total = 0
8+
for i in range(1, num + 1):
9+
if num % i == 0:
10+
total += 1
11+
12+
question = f'{num}'
13+
if total <= 2:
14+
answaer = 'yes'
15+
else:
16+
answaer = 'no'
17+
18+
return(question, answaer)

brain_games/scripts/brain_prime.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from brain_games.game_skeleton import game_start
2+
from brain_games.games import prime
3+
4+
5+
def main():
6+
game_start(prime)
7+
8+
9+
if __name__ == "__main__":
10+
main()

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ brain-games = "brain_games.scripts.brain_games:main"
2525
brain-even = "brain_games.scripts.brain_even:main"
2626
brain-calc = "brain_games.scripts.brain_calc:main"
2727
brain-gcd = "brain_games.scripts.brain_gcd:main"
28-
brain-progression = "brain_games.scripts.brain_progression:main"
28+
brain-progression = "brain_games.scripts.brain_progression:main"
29+
brain-prime = "brain_games.scripts.brain_prime:main"

0 commit comments

Comments
 (0)