forked from honix/pythonintask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_12_7
More file actions
51 lines (48 loc) · 1.06 KB
/
task_12_7
File metadata and controls
51 lines (48 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Задача 12. Вариант 7.
# Разработайте игру "Крестики-нолики". (см. М.Доусон Программируем на Python гл. 6)
# Videneev P. A.
# 26.05.2016
import random
#крестики-нолики
X = "X"
O = "O"
EMPTY = " "
TIE = "ничья"
NUM_SQUARES = 9
def main():
return 0
def display_instruct():
print ("""
0 | 1 | 2
—-----—
3 | 4 | 5
—-----—
6 | 7 | 8
""")
def ask_yes_no(question):
response = None
while response not in ("y", "n"):
response = input (question).lower()
return response
def ask_number(question, low, high):
response = None
while response not in range(low, high):
response = int(input(question))
return response
def pieces():
go_first = ask_yes_no("Кто ходит первым?\n")
if go_first == "y":
print ("Твой ход!")
human = X
computer = O
else:
print ("Начинаю")
human = O
computer = X
return computer, human
def new_board():
board = []
for square in range(NUM_SQUARES):
board.append(EMPTY)
return board
def display_board(board):