Skip to content

Commit 5ffdf82

Browse files
committed
created brain-prime
1 parent 4d1c1ee commit 5ffdf82

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
[![asciicast](https://asciinema.org/a/ilpAZLSeYs7cnTFNXKphTY2sE.svg)](https://asciinema.org/a/ilpAZLSeYs7cnTFNXKphTY2sE)
1111

1212
[![asciicast](https://asciinema.org/a/4gBKCW81ohjkwn8sa7EqY5xvC.svg)](https://asciinema.org/a/4gBKCW81ohjkwn8sa7EqY5xvC)
13+
14+
[![asciicast](https://asciinema.org/a/5MSWhTzT80RNfbNaKSwFhBHD0.svg)](https://asciinema.org/a/5MSWhTzT80RNfbNaKSwFhBHD0)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import random
2+
3+
import prompt
4+
5+
from brain_games.scripts.hello_user import weclome_user
6+
from brain_games.scripts.helper_script import checking_answers
7+
8+
9+
def prime(number):
10+
if number == 1:
11+
flag = 'no'
12+
return flag
13+
for i in range(2, int(number ** 0.5) + 1):
14+
if number % i == 0:
15+
flag = 'no'
16+
return flag
17+
else:
18+
flag = 'yes'
19+
return flag
20+
21+
22+
def main():
23+
name = weclome_user()
24+
print('Answer "yes" if given number is prime. Otherwise answer "no".')
25+
count = 0
26+
27+
while True:
28+
number = random.randint(1, 1000)
29+
flag = prime(number)
30+
print(f'Question: {number}')
31+
answer = prompt.string('Your answer: ')
32+
33+
if not checking_answers(flag, answer, count, name):
34+
break
35+
count += 1
36+
37+
38+
if __name__ == '__main__':
39+
main()

demo_4.cast

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{"version": 2, "width": 136, "height": 40, "timestamp": 1739817080, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2+
[0.061523, "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+
[1.002309, "o", "b"]
4+
[1.176435, "o", "r"]
5+
[1.421454, "o", "a"]
6+
[1.603614, "o", "i"]
7+
[1.845496, "o", "n"]
8+
[2.612219, "o", "-"]
9+
[2.929064, "o", "p"]
10+
[3.064042, "o", "r"]
11+
[3.368335, "o", "i"]
12+
[3.676619, "o", "m"]
13+
[3.80159, "o", "e"]
14+
[4.249208, "o", "\r\n\u001b[?2004l\r"]
15+
[4.275889, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
16+
[5.059205, "o", "P"]
17+
[5.225661, "o", "a"]
18+
[5.536337, "o", "v"]
19+
[5.732323, "o", "e"]
20+
[6.068706, "o", "l"]
21+
[6.382022, "o", "\r\n"]
22+
[6.382572, "o", "Hello, Pavel!\r\nAnswer \"yes\" if given number is prime. Otherwise answer \"no\".\r\nQuestion: 816\r\nYour answer: "]
23+
[10.415207, "o", "n"]
24+
[10.820472, "o", "o"]
25+
[11.201624, "o", "\r\n"]
26+
[11.201956, "o", "Correct!\r\nQuestion: 139\r\nYour answer: "]
27+
[16.311917, "o", "y"]
28+
[16.41413, "o", "e"]
29+
[16.669026, "o", "s"]
30+
[16.983832, "o", "\r\n"]
31+
[16.983963, "o", "Correct!\r\nQuestion: 818\r\n"]
32+
[16.984312, "o", "Your answer: "]
33+
[22.898036, "o", "n"]
34+
[23.309287, "o", "o"]
35+
[23.620587, "o", "\r\n"]
36+
[23.620756, "o", "Correct!\r\nCongratulations, Pavel!\r\n"]
37+
[23.626959, "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$ "]
38+
[24.361003, "o", "brain-prime"]
39+
[25.032399, "o", "\r\n\u001b[?2004l\r"]
40+
[25.05911, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
41+
[26.327916, "o", "P"]
42+
[26.490085, "o", "a"]
43+
[26.817069, "o", "v"]
44+
[27.059607, "o", "e"]
45+
[27.279366, "o", "l"]
46+
[27.639219, "o", "\r\n"]
47+
[27.639596, "o", "Hello, Pavel!\r\nAnswer \"yes\" if given number is prime. Otherwise answer \"no\".\r\nQuestion: 536\r\nYour answer: "]
48+
[28.75484, "o", "n"]
49+
[29.097352, "o", "o"]
50+
[29.353391, "o", "\r\n"]
51+
[29.353661, "o", "Correct!\r\nQuestion: 232\r\nYour answer: "]
52+
[30.714371, "o", "n"]
53+
[31.207434, "o", "o"]
54+
[32.211421, "o", "\b \b"]
55+
[32.378516, "o", "\b \b"]
56+
[33.088641, "o", "y"]
57+
[33.17133, "o", "e"]
58+
[33.371915, "o", "s"]
59+
[33.507098, "o", "\r\n"]
60+
[33.507416, "o", "'yes' is wrong answer ;(. Correct answer was 'no'.\r\nLet's try again, Pavel\r\n"]
61+
[33.512728, "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$ "]
62+
[36.309021, "o", "e"]
63+
[36.516594, "o", "x"]
64+
[36.695715, "o", "i"]
65+
[36.899428, "o", "t"]
66+
[37.096193, "o", "\r\n\u001b[?2004l\rexit\r\n"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ brain-even = "brain_games.scripts.games.brain_even:main"
2626
brain-calc = "brain_games.scripts.games.brain_calc:main"
2727
brain-gcd = "brain_games.scripts.games.brain_gcd:main"
2828
brain-progression = "brain_games.scripts.games.brain_progression:main"
29+
brain-prime = "brain_games.scripts.games.brain_prime:main"

0 commit comments

Comments
 (0)