Skip to content

Commit c4cf533

Browse files
committed
check 2
1 parent 3ad9364 commit c4cf533

24 files changed

+131
-71
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.venv
2+
.python-version
23
demo.cast
3-
__pycache__/
4+
__pycache__
5+
.idea
6+
.DS_Store
7+
**/__pycache__/

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,27 @@ install:
44
brain-games:
55
uv run brain-games
66

7+
brain-even:
8+
uv run brain-even
9+
10+
brain-calc:
11+
uv run brain-calc
12+
13+
brain-gcd:
14+
uv run brain-gcd
15+
16+
brain-progression:
17+
uv run brain-progression
18+
19+
brain-prime:
20+
uv run brain-prime
21+
722
build:
823
uv build
924

1025
package-install:
1126
uv tool install dist/*.whl --force
1227

13-
make lint:
28+
lint:
1429
uv run ruff check brain_games
1530

README.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
1+
The game "Brain-games" includes 5 games.
2+
To win each game, you need to give 3 correct answers.
3+
4+
brain-even:
5+
You need to answer "yes" if given number is even, otherwise answer "no".
6+
7+
brain-calc:
8+
You need to write down thr calculation resuits.
9+
10+
brain-gcd:
11+
Find the greatest common divisor of given numbers.
12+
13+
brain-progression:
14+
You need to write down which number is missing in the progression.
15+
16+
brain-prime:
17+
You need to answer "yes" if given number is prime. Otherwise answer "no".
18+
19+
### Commands for calling games:
20+
brain-even
21+
brain-calc
22+
brain-gcd
23+
brain-progression
24+
brain-prime
25+
126
### Hexlet tests and linter status:
227
[![Actions Status](https://github.com/s-gala/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/s-gala/python-project-49/actions)
328

429
### CodeClimate
530
[![Maintainability](https://api.codeclimate.com/v1/badges/487e17fe16141caa4b2a/maintainability)](https://codeclimate.com/github/s-gala/python-project-49/maintainability)
631

32+
### This project use:
33+
Python >= 3.10
34+
prompt >= 0.4.1
35+
36+
### Install
37+
38+
git clone https://github.com/s-gala/python-project-49.git
39+
cd python-project-49
40+
make package-install
41+
42+
### Removal
43+
cd pyton-project-49
44+
cd ../
45+
rm -rf python-project-49
46+
747
### Asciinema even
8-
[![Demo](https://asciinema.org/a/d0DER5mtYI6eUx8QrBAQuZPD7)
48+
[![Demo]( https://asciinema.org/a/wRnu8Sf53kCCvUfgqQixs0EPh )
949

10-
### Asciinema even calc
11-
[![Demo](https://asciinema.org/a/I5Igo5X4xIsyGS50CBBa0Qcld)
50+
### Asciinema calc
51+
[![Demo]( https://asciinema.org/a/S9Bly86EkmrpnTJhsAJU8pQDl )
1252

1353
### Asciinema gcd
14-
[![Demo](https://asciinema.org/a/Sa6xEYjF5SZ9GlKZXa1UAEqUo)
54+
[![Demo]( https://asciinema.org/a/L5FDJeBgVySllsh5oELOwTtKa )
1555

1656
### Asciinema progression
17-
[![Demo](https://asciinema.org/a/bCwx5SdlyhaWnMn1TQZIDxtuW)
57+
[![Demo]( https://asciinema.org/a/geOtpvl2IneSE65iIyp3BSoGY )
1858

1959
### Asciinema prime
20-
[![Demo](https://asciinema.org/a/PyxW5Rn3Wu3LMM1EyiPQGu9m3)
60+
[![Demo]( https://asciinema.org/a/j2PgQoMiKCmVM1duYVp8pnN3i )

brain_games/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33

44
def welcome_user():
5+
print("Welcome to the Brain Games!")
56
name = prompt.string('May I have your name? ')
6-
print('Hello, ' + name + '!')
7+
print(f'Hello, {name}!')
-25 Bytes
Binary file not shown.
23 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

brain_games/games/calc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import operator
2+
import random
3+
4+
INSTRUCTION = "What is result of the expression?"
5+
6+
7+
def question_answer_calc():
8+
from brain_games.games import random_number
9+
x = random_number.get_random_number(1, 100)
10+
y = random_number.get_random_number(1, 100)
11+
math_symbol = {'+': operator.add,
12+
'-': operator.sub,
13+
'*': operator.mul}
14+
op = random.choice(list(math_symbol.keys()))
15+
random_question = f'{x}{op}{y}'
16+
right_answer = str(math_symbol.get(op)(x, y))
17+
return random_question, right_answer

brain_games/games/for_all_games.py renamed to brain_games/games/engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def welcome_user(INSTRUCTION):
99

1010

1111
def game_engine(random_question, right_answer, name):
12-
print('Question: ' + str(random_question))
12+
print(f"Question: {random_question}")
1313
answer = prompt.string('Your answer: ')
1414
if right_answer != answer:
1515
print(f"'{answer}' is wrong answer;(. ", end='')

brain_games/games/for_brain_even.py renamed to brain_games/games/even.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from random import randint
2-
31
INSTRUCTION = 'Answer "yes" if the number is even, otherwise answer "no".'
42

53

64
def question_answer_even():
7-
random_question = randint(1, 100)
5+
from brain_games.games import random_number
6+
random_question = random_number.get_random_number(1, 100)
87
right_answer = ''
98
if random_question % 2 == 0:
109
right_answer = 'yes'

0 commit comments

Comments
 (0)