Skip to content

Commit ef289fd

Browse files
committed
created brain-even
1 parent e77b9b8 commit ef289fd

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
[![Actions Status](https://github.com/P-Solod/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/P-Solod/python-project-49/actions)
33

44
[![Maintainability](https://api.codeclimate.com/v1/badges/e9fd145072b912372b3e/maintainability)](https://codeclimate.com/github/P-Solod/python-project-50/maintainability)
5+
6+
[![asciicast](https://asciinema.org/a/klBAIJgaHlmUxnNpXJSDnMRZn.svg)](https://asciinema.org/a/klBAIJgaHlmUxnNpXJSDnMRZn)

brain_games/scripts/brain_even.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import random
2+
3+
import prompt
4+
5+
6+
def main():
7+
print('Welcome to the Brain Games!')
8+
name = prompt.string('May I have your name? ')
9+
print(f'Hello, {name}!')
10+
print('Answer "yes" if the number is even, otherwise answer "no".')
11+
12+
count = 0
13+
14+
while count < 3:
15+
numbers = random.randint(1, 100)
16+
if numbers % 2 == 0:
17+
flag = 'yes'
18+
else:
19+
flag = 'no'
20+
21+
print(f'Question: {numbers}')
22+
answer = prompt.string('Your answer: ')
23+
24+
if answer == flag:
25+
count += 1
26+
print('Correct!')
27+
else:
28+
print(f"'{answer}' is wrong answer ;(. "
29+
f"Correct answer was '{flag}'.")
30+
print(f"Let's try again, {name}!")
31+
break
32+
33+
else:
34+
print(f'Congratulations, {name}!')
35+
36+
37+
if __name__ == "__main__":
38+
main()

demo.cast

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{"version": 2, "width": 120, "height": 23, "timestamp": 1739118585, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2+
[0.032131, "o", "\u001b[?2004h\u001b]0;mitsyaki@DESKTOP-SKJO0UG: ~/python-project-49\u0007\u001b[01;32mmitsyaki@DESKTOP-SKJO0UG\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
3+
[0.922103, "o", "b"]
4+
[1.041935, "o", "r"]
5+
[1.248783, "o", "a"]
6+
[1.428216, "o", "i"]
7+
[1.616369, "o", "n"]
8+
[2.371352, "o", "-"]
9+
[2.505579, "o", "e"]
10+
[2.735522, "o", "v"]
11+
[2.872659, "o", "e"]
12+
[3.218579, "o", "n"]
13+
[3.610632, "o", "\r\n\u001b[?2004l\r"]
14+
[3.63682, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
15+
[4.463418, "o", "P"]
16+
[4.597711, "o", "a"]
17+
[4.818817, "o", "v"]
18+
[4.973017, "o", "e"]
19+
[5.15871, "o", "l"]
20+
[5.664387, "o", "\r\n"]
21+
[5.664758, "o", "Hello, Pavel!\r\nAnswer \"yes\" if the number is even, otherwise answer \"no\".\r\nQuestion: 38\r\nYour answer: "]
22+
[6.796759, "o", "y"]
23+
[6.895868, "o", "e"]
24+
[7.135892, "o", "s"]
25+
[7.32644, "o", "\r\n"]
26+
[7.326724, "o", "Correct!\r\nQuestion: 87\r\nYour answer: "]
27+
[8.473412, "o", "n"]
28+
[8.79759, "o", "o"]
29+
[9.027841, "o", "\r\n"]
30+
[9.028144, "o", "Correct!\r\nQuestion: 32\r\nYour answer: "]
31+
[10.3181, "o", "y"]
32+
[10.456319, "o", "e"]
33+
[10.71268, "o", "s"]
34+
[11.014715, "o", "\r\n"]
35+
[11.01499, "o", "Correct!\r\nCongratulations, Pavel!\r\n"]
36+
[11.020153, "o", "\u001b[?2004h\u001b]0;mitsyaki@DESKTOP-SKJO0UG: ~/python-project-49\u0007\u001b[01;32mmitsyaki@DESKTOP-SKJO0UG\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
37+
[11.790313, "o", "brain-even"]
38+
[12.22621, "o", "\r\n\u001b[?2004l\r"]
39+
[12.25276, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
40+
[13.677432, "o", "P"]
41+
[13.845224, "o", "a"]
42+
[14.156637, "o", "v"]
43+
[14.386174, "o", "e"]
44+
[15.021569, "o", "l"]
45+
[15.63767, "o", "\r\n"]
46+
[15.63796, "o", "Hello, Pavel!\r\nAnswer \"yes\" if the number is even, otherwise answer \"no\".\r\nQuestion: 78\r\nYour answer: "]
47+
[17.220339, "o", "n"]
48+
[17.575285, "o", "o"]
49+
[17.943402, "o", "\r\n"]
50+
[17.943662, "o", "'no' is wrong answer ;(. Correct answer was 'yes'.\r\nLet's try again, Pavel!\r\n"]
51+
[17.949112, "o", "\u001b[?2004h\u001b]0;mitsyaki@DESKTOP-SKJO0UG: ~/python-project-49\u0007\u001b[01;32mmitsyaki@DESKTOP-SKJO0UG\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
52+
[19.580378, "o", "e"]
53+
[19.983851, "o", "x"]
54+
[20.366538, "o", "i"]
55+
[20.57951, "o", "t"]
56+
[21.049457, "o", "\r\n\u001b[?2004l\r"]
57+
[21.049746, "o", "exit\r\n"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dev = [
2222

2323
[project.scripts]
2424
brain-games = "brain_games.scripts.brain_games:main"
25+
brain-even = "brain_games.scripts.brain_even:main"

0 commit comments

Comments
 (0)