try:
element = WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.ID, "mySuperId"))
)
finally:
driver.quit()
alert_is_present
element_to_be_clickable
text_to_be_present_in_element
visibility_of
В классе Player должны быть:
-Конструктор для установки выбора варианта и имени
-Значения для конструктора по умолчанию
-Функция WhoWins принимающая два объекта, и возвращающая строку: "имя победителя" или "ничья".
return f
f"Баланс: {balance}, font = undertext, fill="#ffffff")
def take_input_from_keyboard(message):
keyboard_input = input(f'{message}')
return keyboard_input
def row_constructor(row_number):
message = f'Enter the values of your row number {row_number}: '
rows_values_raw = take_input_from_keyboard(message)
row = string_array_to_int_array_constructor(rows_values_raw)
return row
def matrix_constructor():
message = 'Input the count of rows: '
rows_count = int(take_input_from_keyboard(message))
matrix = []
for i in range(rows_count):
row = row_constructor(i + 1)
row_len_check(row, i)
matrix.append(row)
return matrix
def string_array_to_int_array_constructor(raw_string):
int_array = []
string_array = raw_string.split()
while len(string_array):
next_number = int(string_array.pop(0))
int_array.append(next_number)
return int_array
def row_len_check(row, iteration):
"""
if it's first iteration: creating row lenght reference
if second dnd above: comparasion row lenght with reference
if row lenght and referece not equal, raise exception
"""
if iteration == 0:
global reference
reference = len(row)
return
for i in range(len(row)):
if len(row) != reference:
raise Exception
return
def matrix_print(matrix):
for rows in range(len(matrix)):
for element in range(len(matrix[rows])):
element = int(element)
print(matrix[rows][element], end=' ')
print()
return
def main():
matrix = matrix_constructor()
matrix_print(matrix)
main()
class Message:
def __init__(self, message):
self.rs = ['п', 'р', 'и', 'в', 'е','т']
self.en = ['p', 'r', 'i', 'v', 'e', 't']
self.ss = (self.rs, self.en)
self.cc = {r: e for r, e in zip(*self.ss)}
self.text = message
def translate(self, text):
trans = ''.join([self.cc[i] for i in text])
return trans
def show(self):
print(self.text)
def __repr__(self):
return self.translate(self.text)
chat_message1 = Message('привет')
chat_message1.show()
print(chat_message1)
self.text = message
...
def __repr__(self):
return self.translate(self.text)
self.text = self.translate(message)
...
def __repr__(self):
return self.text
def x_here(x,y):
if area[x][y][text] == X:
return True
else:
return False
if x_here(0,0) and x_here(0,1) and x_here(0,2):
return "X"
win_condition_topleft_to_botright = ((0,0),(0,1),(0,2))
def check_win_condition(first, second, third):
"""на вход три кортежа, являющиеся координатами игрового поля"""
if x_here(*first) and x_here(*second) and x_here(*third):
return "X"
def winner():
check_win_condition(*win_condition_topleft_to_botright)
check_win_condition(*win_condition_2)
check_win_condition(*win_condition_3)
check_win_condition(*win_condition_4)
Ah shit, here we go again
text_color = (1, 1, 1) #по умолчанию текст красный
if score >10:
text_color = (2, 2, 2) #если оценка оказалась выше 10, то меняем цвет
if score > 50:
text_color = (3, 3, 3) #можно увеличить количество цветов, в зависимости от оценки
cv2.putText(
img = img,
text = str(score1),
org = (0, 50),
fontFace = cv2.FONT_HERSHEY_DUPLEX,
fontScale = 2.0,
color = text_color,
thickness = 3
)