File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ from brain_games .engine import run_game
2+ from brain_games .utils import get_random_num
3+ from brain_games .consts import PRIME_INSTRUCTION
4+
5+
6+ def is_prime (num ):
7+ deviders_num = 0
8+ square_root = int (num ** (1 / 2 ))
9+ for i in range (2 , square_root + 1 ):
10+ if num % i == 0 :
11+ deviders_num += 1
12+ return deviders_num == 0
13+
14+
15+ def get_num_and_answer ():
16+ num = get_random_num ()
17+ correct_answer = 'yes' if is_prime (num ) else 'no'
18+ return num , correct_answer
19+
20+
21+ def run_prime_game ():
22+ run_game (get_num_and_answer , PRIME_INSTRUCTION )
Original file line number Diff line number Diff line change 1+ from brain_games .games .prime import run_prime_game
2+
3+
4+ def main ():
5+ run_prime_game ()
6+
7+
8+ if __name__ == "__main__" :
9+ main ()
You can’t perform that action at this time.
0 commit comments