File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44[ ![ Quality Gate Status] ( https://sonarcloud.io/api/project_badges/measure?project=UlianaPythonBackendDeveloper_python-project-49&metric=alert_status )] ( https://sonarcloud.io/summary/new_code?id=UlianaPythonBackendDeveloper_python-project-49 )
55
6-
6+ ## brain_even
7+ ** Что нужно вычислить:** ``
78[ ![ brain_even demo]] ( https://asciinema.org/a/f5fiuSRHAotzjtYc )
89
10+
11+ ## brain-calc
12+
13+ ** Что нужно вычислить:** ` 35 + 16 `
14+
15+ ** Запуск:** ` python3 -m brain_games.scripts.brain_calc `
916[ ![ brain-calc demo]] ( https://asciinema.org/a/L7I07nWmyZyjfuqr )
Original file line number Diff line number Diff line change @@ -24,24 +24,24 @@ def main():
2424 name = welcome_user ()
2525 print (DISCRIPTION )
2626
27- correct_answer = 0
27+ correct_answers = 0
2828
29- while correct_answer < 3 :
29+ while correct_answers < 3 :
3030 correct_answer , question = get_expression ()
3131
3232 print (f"Question: { question } " )
3333 user_answer = input ("You answer: " ).strip ()
3434
3535 if user_answer == correct_answer :
3636 print ("Correct!" )
37- correct_answer += 1
37+ correct_answers += 1
3838 else :
3939 print (f"'{ user_answer } ' is wrong answer; (. " , end = "" )
4040 print (f"Correct answer was '{ correct_answer } '." )
4141 print (f"Let's try again, { name } !" )
4242 break
4343
44- if correct_answer == 3 :
44+ if correct_answers == 3 :
4545 print (f"Congratulations, { name } !" )
4646
4747if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -9,26 +9,29 @@ def is_even(number):
99 return number % 2 == 0
1010
1111
12- def brain_even ():
12+ def main ():
1313 name = welcome_user ()
14- print (DESCTRIPTION )
15-
16- correct_answers = 0
17-
14+ print ("Answer 'yes' if the number is even, otherwise answer 'no'." )
15+
16+ correct_answers = 0
17+
1818 while correct_answers < 3 :
1919 question = random .randint (1 , 100 )
20+ correct_answer = 'yes' if is_even (question ) else 'no'
21+
2022 print (f"Question: { question } " )
21- answer = prompt .string ("You anwser : " ).lower ()
22-
23- if answer == correct_answers :
23+ user_answer = prompt .string ("Your answer : " ).lower (). strip ()
24+
25+ if user_answer == correct_answer :
2426 print ("Correct!" )
2527 correct_answers += 1
2628 else :
27- print (f"'{ answer } ' is wrong answer ;(. Correct answer was '{ correct_answers } '." )
29+ print (f"'{ user_answer } ' is wrong answer; (. " )
30+ print (f"Correct answer was '{ correct_answer } '." )
2831 print (f"Let's try again, { name } !" )
29- return
30-
31- print (f"Congratulations,{ name } !" )
32-
32+ break
33+ if correct_answers == 3 :
34+ print (f"Congratulations, { name } !" )
35+
3336if __name__ == '__main__' :
34- brain_even ()
37+ main ()
Original file line number Diff line number Diff line change 1- #!/usr/bin/env python3
2- import sys
3- import os
4- sys .path .insert (0 , os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
5- from cli import welcome_user
1+
2+ from brain_games .cli import welcome_user
63
74def main ():
85 welcome_user ()
You can’t perform that action at this time.
0 commit comments