Skip to content

Commit 8b713de

Browse files
launch the first game
1 parent 20c3ceb commit 8b713de

File tree

5 files changed

+254
-1
lines changed

5 files changed

+254
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
### Hexlet tests and linter status:
22
[![Actions Status](https://github.com/ivanvasutinskiy/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/ivanvasutinskiy/python-project-49/actions)
33

4-
[![Maintainability](https://api.codeclimate.com/v1/badges/5e002949e4c499150d5e/maintainability)](https://codeclimate.com/github/ivanvasutinskiy/python-project-49/maintainability)
4+
[![Maintainability](https://api.codeclimate.com/v1/badges/5e002949e4c499150d5e/maintainability)](https://codeclimate.com/github/ivanvasutinskiy/python-project-49/maintainability)
5+
6+
### Installation and first run:
7+
8+
[![asciicast](https://asciinema.org/a/JBZ5IDG4RcQpDtCl0nX0dHb3z.svg)](https://asciinema.org/a/JBZ5IDG4RcQpDtCl0nX0dHb3z)
0 Bytes
Binary file not shown.

brain_games/scripts/brain_even.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from random import randint
2+
from brain_games.cli import welcome_user
3+
4+
5+
6+
7+
def main():
8+
name = welcome_user()
9+
10+
flag = True
11+
print('Answer "yes" if the number is even, otherwise answer "no".')
12+
n = 0
13+
while n!=3:
14+
num = randint(1, 100)
15+
if num % 2 == 0:
16+
flag = True
17+
else:
18+
flag = False
19+
20+
print(f'Question: {num}')
21+
answer = input('Your answer: ')
22+
if answer == 'yes' and flag == True:
23+
print('Correct!')
24+
n +=1
25+
elif answer == 'no' and flag == False:
26+
print('Correct!')
27+
n +=1
28+
else:
29+
if answer == 'yes':
30+
print(f"'yes' is wrong answer ;(. Correct answer was 'no'.\nLet's try again, {name}!")
31+
break
32+
elif answer == 'no':
33+
print(f"'no' is wrong answer ;(. Correct answer was 'yes'.\nLet's try again, {name}!")
34+
break
35+
else:
36+
print(f"use only 'yes' or 'no'.\nLet's try again, {name}!")
37+
break
38+
39+
40+
if n == 3:
41+
print(f'Congratulations, {name}!')
42+
43+
44+
if __name__ == "__main__":
45+
main()
46+
47+
48+
49+

demo.cast

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
{"version": 2, "width": 120, "height": 30, "timestamp": 1736163214, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2+
[0.007784, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
3+
[5.672188, "o", "m"]
4+
[5.792166, "o", "a"]
5+
[7.152184, "o", "k"]
6+
[7.384106, "o", "e"]
7+
[7.663859, "o", " "]
8+
[10.231918, "o", "i"]
9+
[10.53594, "o", "n"]
10+
[10.679806, "o", "s"]
11+
[10.928124, "o", "t"]
12+
[11.136034, "o", "a"]
13+
[11.496167, "o", "l"]
14+
[11.648354, "o", "l"]
15+
[12.496292, "o", "\r\n\u001b[?2004l\r"]
16+
[12.497241, "o", "uv sync\r\n"]
17+
[12.500819, "o", "\u001b[2mResolved \u001b[1m3 packages\u001b[0m \u001b[2min 0.46ms\u001b[0m\u001b[0m\r\n"]
18+
[12.501074, "o", "\u001b[2mAudited \u001b[1m3 packages\u001b[0m \u001b[2min 0.03ms\u001b[0m\u001b[0m\r\n"]
19+
[12.501755, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
20+
[14.440351, "o", "m"]
21+
[14.552329, "o", "a"]
22+
[15.296458, "o", "k"]
23+
[15.560351, "o", "e"]
24+
[15.768376, "o", " "]
25+
[18.696018, "o", "b"]
26+
[19.176425, "o", "u"]
27+
[19.368418, "o", "i"]
28+
[19.584186, "o", "l"]
29+
[20.048436, "o", "d"]
30+
[23.256573, "o", "\r\n\u001b[?2004l\r"]
31+
[23.257515, "o", "uv build\r\n"]
32+
[23.260566, "o", "\u001b[1mBuilding source distribution...\u001b[0m\r\n"]
33+
[23.906294, "o", "\u001b[1mBuilding wheel from source distribution...\u001b[0m\r\n"]
34+
[24.044918, "o", "Successfully built \u001b[36m\u001b[1mdist/hexlet_code-0.1.0.tar.gz"]
35+
[24.045072, "o", "\u001b[0m\u001b[39m\r\nSuccessfully built \u001b[36m\u001b[1mdist/hexlet_code-0.1.0-py3-none-any.whl\u001b[0m\u001b[39m\r\n"]
36+
[24.04646, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
37+
[27.824448, "o", "m"]
38+
[27.960604, "o", "a"]
39+
[29.160647, "o", "k"]
40+
[29.304894, "o", "e"]
41+
[29.456613, "o", " "]
42+
[30.112753, "o", "p"]
43+
[30.240745, "o", "a"]
44+
[30.85673, "o", "c"]
45+
[32.208741, "o", "k"]
46+
[32.328688, "o", "a"]
47+
[35.360785, "o", "g"]
48+
[35.528784, "o", "e"]
49+
[36.44878, "o", "-"]
50+
[36.864485, "o", "i"]
51+
[37.176802, "o", "n"]
52+
[37.384544, "o", "s"]
53+
[37.608812, "o", "t"]
54+
[37.776795, "o", "a"]
55+
[38.120843, "o", "l"]
56+
[38.280835, "o", "l"]
57+
[40.152901, "o", "\r\n\u001b[?2004l\r"]
58+
[40.153887, "o", "uv tool install dist/*.whl\r\n"]
59+
[40.158655, "o", "\u001b[37m⠋\u001b[0m \u001b[2mResolving dependencies... \u001b[0m"]
60+
[40.158764, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mResolving dependencies... \u001b[0m\r\u001b[2K"]
61+
[40.159158, "o", "\u001b[37m⠋\u001b[0m \u001b[2mResolving dependencies... \u001b[0m"]
62+
[40.159239, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mResolving dependencies... \u001b[0m"]
63+
[40.159811, "o", "\r\u001b[2K"]
64+
[40.159897, "o", "\u001b[37m⠋\u001b[0m \u001b[2mResolving dependencies... \u001b[0m"]
65+
[40.15999, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mResolving dependencies... \u001b[0m"]
66+
[40.160166, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mhexlet-code==0.1.0 \u001b[0m"]
67+
[40.160369, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mprompt==0.4.1 \u001b[0m"]
68+
[40.160545, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2m \u001b[0m\r\u001b[2K"]
69+
[40.160667, "o", "\u001b[2mResolved \u001b[1m2 packages\u001b[0m \u001b[2min 1ms\u001b[0m\u001b[0m\r\n"]
70+
[40.161614, "o", "\u001b[37m⠋\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/0) \r\u001b[2K\u001b[37m⠋\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1) "]
71+
[40.161728, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2mPreparing packages...\u001b[0m (0/1) "]
72+
[40.163538, "o", "\r\u001b[2K\u001b[37m⠙\u001b[0m \u001b[2m\u001b[0m (1/1) \r\u001b[2K\u001b[2m"]
73+
[40.163577, "o", "Prepared \u001b[1m1 package\u001b[0m \u001b[2min 2ms\u001b[0m\u001b[0m\r\n"]
74+
[40.163709, "o", "░░░░░░░░░░░░░░░░░░░░ [0/0] \u001b[2mInstalling wheels... \u001b[0m\r\u001b[2K░░░░░░░░░░░░░░░░░░░░ [0/2] \u001b[2mInstalling wheels... \u001b[0m"]
75+
[40.16437, "o", "\r\u001b[2K░░░░░░░░░░░░░░░░░░░░ [0/2] \u001b[2mprompt==0.4.1 \u001b[0m\r\u001b[2K██████████░░░░░░░░░░ [1/2] \u001b[2mprompt==0.4.1 \u001b[0m"]
76+
[40.165399, "o", "\r\u001b[2K██████████░░░░░░░░░░ [1/2] \u001b[2mhexlet-code==0.1.0 (from file:///home/ivan/python-project-49/dist/hexlet_code-0.1.0-py3-none-\u001b[0m\r\u001b[2K████████████████████ [2/2] \u001b[2mhexlet-code==0.1.0 (from file:///home/ivan/python-project-49/dist/hexlet_code-0.1.0-py3-none-\u001b[0m"]
77+
[40.165486, "o", "\r\u001b[2K\u001b[2mInstalled \u001b[1m2 packages\u001b[0m \u001b[2min 1ms\u001b[0m\u001b[0m\r\n \u001b[32m+\u001b[39m"]
78+
[40.165607, "o", " \u001b[1mhexlet-code\u001b[0m\u001b[2m==0.1.0 (from file:///home/ivan/python-project-49/dist/hexlet_code-0.1.0-py3-none-any.whl"]
79+
[40.165686, "o", ")\u001b[0m\r\n \u001b[32m+\u001b[39m \u001b[1mprompt\u001b[0m\u001b[2m==0.4.1\u001b[0m\r\n"]
80+
[40.165944, "o", "Installed 2 executables: "]
81+
[40.166043, "o", "\u001b[1mbrain-even\u001b[0m, \u001b[1mbrain-games\u001b[0m\r\n"]
82+
[40.167333, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
83+
[45.048714, "o", "make package-install"]
84+
[45.88868, "o", "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\u001b[10Pbuild"]
85+
[46.537096, "o", "\b\b\b\b\binstall"]
86+
[47.313042, "o", "\b\u001b[K"]
87+
[47.800517, "o", "\b\u001b[K"]
88+
[47.846373, "o", "\b\u001b[K"]
89+
[47.877172, "o", "\b\u001b[K"]
90+
[47.912563, "o", "\b\u001b[K"]
91+
[47.932029, "o", "\b\u001b[K"]
92+
[47.979398, "o", "\b\u001b[K"]
93+
[48.010794, "o", "\b\u001b[K"]
94+
[48.045606, "o", "\b\u001b[K"]
95+
[48.077188, "o", "\b\u001b[K"]
96+
[48.108839, "o", "\b\u001b[K"]
97+
[48.139272, "o", "\b\u001b[K"]
98+
[48.171189, "o", "\u0007"]
99+
[48.202066, "o", "\u0007"]
100+
[48.236676, "o", "\u0007"]
101+
[48.264924, "o", "\u0007"]
102+
[48.315907, "o", "\u0007"]
103+
[48.3353, "o", "\u0007"]
104+
[48.375303, "o", "\u0007"]
105+
[48.40359, "o", "\u0007"]
106+
[48.431648, "o", "\u0007"]
107+
[48.482561, "o", "\u0007"]
108+
[48.502019, "o", "\u0007"]
109+
[48.537434, "o", "\u0007"]
110+
[50.576769, "o", "b"]
111+
[50.768756, "o", "a"]
112+
[51.624833, "o", "\b\u001b[K"]
113+
[51.857118, "o", "r"]
114+
[51.984516, "o", "a"]
115+
[52.673159, "o", "i"]
116+
[53.289161, "o", "n"]
117+
[54.753357, "o", "-"]
118+
[55.984928, "o", "g"]
119+
[56.193209, "o", "a"]
120+
[56.569196, "o", "m"]
121+
[56.92136, "o", "e"]
122+
[57.112773, "o", "s"]
123+
[58.969384, "o", "\r\n\u001b[?2004l\r"]
124+
[58.980453, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
125+
[60.353255, "o", "I"]
126+
[61.137282, "o", "v"]
127+
[61.329278, "o", "a"]
128+
[61.513303, "o", "n"]
129+
[62.641431, "o", "\r\n"]
130+
[62.641556, "o", "Hello, Ivan!\r\n"]
131+
[62.643974, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
132+
[64.601394, "o", "b"]
133+
[64.96136, "o", "r"]
134+
[65.096934, "o", "a"]
135+
[65.857394, "o", "i"]
136+
[66.441411, "o", "n"]
137+
[67.009414, "o", "-"]
138+
[67.409171, "o", "e"]
139+
[68.32954, "o", "v"]
140+
[68.689566, "o", "e"]
141+
[69.433487, "o", "n"]
142+
[70.961655, "o", "\r\n\u001b[?2004l\r"]
143+
[70.971476, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
144+
[72.257487, "o", "I"]
145+
[73.001559, "o", "v"]
146+
[73.721507, "o", "a"]
147+
[73.937523, "o", "n"]
148+
[75.833591, "o", "\r\n"]
149+
[75.833632, "o", "Hello, Ivan!\r\nAnswer \"yes\" if the number is even, otherwise answer \"no\".\r\nQuestion: 47\r\n"]
150+
[75.833762, "o", "Your answer: "]
151+
[80.793361, "o", "y"]
152+
[81.161664, "o", "e"]
153+
[81.385351, "o", "s"]
154+
[83.785443, "o", "\r\n"]
155+
[83.785553, "o", "'yes' is wrong answer ;(. Correct answer was 'no'.\r\nLet's try again, Ivan!\r\n"]
156+
[83.788048, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
157+
[87.825878, "o", "b"]
158+
[88.049915, "o", "r"]
159+
[88.169925, "o", "a"]
160+
[88.993621, "o", "i"]
161+
[89.793884, "o", "n"]
162+
[90.505895, "o", "-"]
163+
[90.921914, "o", "g"]
164+
[91.049969, "o", "a"]
165+
[91.401678, "o", "m"]
166+
[91.609956, "o", "e"]
167+
[91.817513, "o", "s"]
168+
[93.39363, "o", "\b\u001b[K"]
169+
[93.585982, "o", "\b\u001b[K"]
170+
[93.761493, "o", "\b\u001b[K"]
171+
[93.946007, "o", "\b\u001b[K"]
172+
[94.145764, "o", "\b\u001b[K"]
173+
[94.825746, "o", "e"]
174+
[95.162008, "o", "v"]
175+
[95.281904, "o", "e"]
176+
[95.474035, "o", "n"]
177+
[96.314024, "o", "\r\n\u001b[?2004l\r"]
178+
[96.323353, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
179+
[97.85811, "o", "I"]
180+
[98.577615, "o", "v"]
181+
[98.713999, "o", "a"]
182+
[98.857605, "o", "n"]
183+
[99.642102, "o", "\r\n"]
184+
[99.642229, "o", "Hello, Ivan!\r\nAnswer \"yes\" if the number is even, otherwise answer \"no\".\r\nQuestion: 51\r\nYour answer: "]
185+
[101.209765, "o", "n"]
186+
[101.370102, "o", "o"]
187+
[102.178139, "o", "\r\n"]
188+
[102.178261, "o", "Correct!\r\nQuestion: 65\r\nYour answer: "]
189+
[103.426166, "o", "n"]
190+
[103.570157, "o", "o"]
191+
[104.161868, "o", "\r\n"]
192+
[104.161977, "o", "Correct!\r\nQuestion: 56\r\nYour answer: "]
193+
[105.73023, "o", "y"]
194+
[105.978195, "o", "e"]
195+
[106.170429, "o", "s"]
196+
[107.130245, "o", "\r\n"]
197+
[107.130364, "o", "Correct!\r\nCongratulations, Ivan!\r\n"]
198+
[107.13274, "o", "\u001b[?2004h\u001b]0;ivan@DESKTOP-1A72GJT: ~/python-project-49\u0007\u001b[01;32mivan@DESKTOP-1A72GJT\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
199+
[109.690349, "o", "\u001b[?2004l\r\r\nexit\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)