-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
127 lines (116 loc) · 4.11 KB
/
main.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import telebot
from telebot import types
from time import sleep
token = '5850676451:AAEIhF1SaboQTn0PHmMha_P8w2BOH9_84aU'
bot = telebot.TeleBot(token)
questions = [
[
"Какой может быть максимальная длинна строки с Flake8?",
"79", "79", "254", "139"
],
[
"Что обозначает переменная int?",
"Целое число",
"Целое число",
"Параметр",
"Строку"
],
[
"Как правильно задать переменной значение?",
"x = 10",
"10 = x",
"x = 10",
"x == 10"
],
[
"Что делает функция len()?",
"Возвращает длинну строки",
"Выдаёт случайное число",
"Возвращает длинну строки",
"Возвращает номер символа"
],
[
"Что делает функция break?",
"Досрочно выходит из цикла",
"Выдаёт случайное число",
"Возвращает длинну строки",
"Досрочно выходит из цикла"
],
[
"Что обозначает переменная str (string)?",
"Строку",
"Целое число",
"Параметр",
"Строку"
],
[
"Что обозначает переменная bool?",
"Да/нет",
"Да/нет",
"Ничего",
"Пустую строку"
],
[
"Укажите оператор ввода:",
"input()",
"input()",
"print()",
"int()"
],
[
"Укажите оператор ввода:",
"input()",
"input()",
"print()",
"int()"
],
[
"Как добавить модуль в программу?",
"import library",
"import library",
"import: library",
"import library.py"
],
[
"Как добавить модуль в программу?",
"import library",
"import library",
"import: library",
"import library.py"
]
]
player_answers = []
@bot.message_handler(commands=['start'])
def button_message(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Да")
markup.add(item1)
bot.send_message(message.chat.id,
text="Хотите начать?",
reply_markup=markup)
@bot.message_handler(content_types=['text'])
def message_reply(message):
if message.text == "Да":
bot.send_message(message.chat.id,
"На каждый вопрос - 7 секунд.")
def quiz(message):
score = 0
for i in range(len(questions)):
keyboard = types.ReplyKeyboardMarkup()
key_1 = types.KeyboardButton(text=questions[i][2])
keyboard.add(key_1)
key_2 = types.KeyboardButton(text=questions[i][3])
keyboard.add(key_2)
key_3 = types.KeyboardButton(text=questions[i][4])
keyboard.add(key_3)
bot.send_message(message.chat.id,
text=questions[i][0],
reply_markup=keyboard)
print(message.text)
sleep(7)
if message.text == questions[i][1]:
score = score + 1
text = f"Ваши баллы: {score}"
bot.send_message(message.chat.id, text=text)
bot.polling(non_stop=True, interval=0)
# RealYozha, 2023