PY
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
#Викторина_ quiz game
#Игра на выбор правильного ответа
#вопросы, которой читаются из текстового файла
import sys
import pickle
from operator import itemgetter
def open_file(file_name, mode):
"""Открывает файл """
try:
the_file = open(file_name, mode, encoding="utf-8")
except IOError as e:
print(f"Невозможно открыть файл {file_name}. Работа программы будет завершена.\n")
input("Нажмите Enter чтобы выйти.")
sys.exit()
else:
return the_file
def next_line(the_file):
"""принимает файловый объект и возвращает отформатированную строку """
line = the_file.readline()
line = line.replace("/", "\n")
return line
def next_block(the_file):
"""Принимает файловый объект и возвращает блок вопроса"""
category = next_line(the_file)
question = next_line(the_file)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run