Choosing a future profession is a very important step in everyone's life. Some school leavers hesitate for a long time, as it is difficult for them to decide, while others, on the contrary, make a firm decision earlier. In order to become what you want, you must first learn and get an education. If you like your future profession very much, then it will be interesting and not difficult to study.
As for me, I want to become a programmer. This profession attracted me when I was in elementary school. Then we started studying computer science, which became my favorite subject. I always listen very carefully to the teacher. I am interested in absolutely all topics on this subject, so I often ask a lot of additional questions in the lessons. At home, I have many different books: about the structure of the computer, about working with different programs, about the basics of programming, about breakdowns, about viruses, and others. In addition, I usually read additional literature on computer science in our school library or search for information that interests me on the Internet.
Если ввод осуществляется через файл, то он должен называть "Слова.txt" и находиться в одной директории с исполняемым файлом. Выбрать нужный вариант ввода можно просто введя цифру в перовом input.
Код:
# -*- coding: utf-8 -*-
format = int(input("Считать слова из файла (введите 1)\nВводить слова в консоль (введите 2)\nВвести слова в одну строку(введите 3)\nВыбор: "))
Choosing a future profession is a very important step in everyone's life. Some school leavers hesitate for a long time, as it is difficult for them to decide, while others, on the contrary, make a firm decision earlier. In order to become what you want, you must first learn and get an education. If you like your future profession very much, then it will be interesting and not difficult to study.
As for me, I want to become a programmer. This profession attracted me when I was in elementary school. Then we started studying computer science, which became my favorite subject. I always listen very carefully to the teacher. I am interested in absolutely all topics on this subject, so I often ask a lot of additional questions in the lessons. At home, I have many different books: about the structure of the computer, about working with different programs, about the basics of programming, about breakdowns, about viruses, and others. In addition, I usually read additional literature on computer science in our school library or search for information that interests me on the Internet.
Объяснение:
Пояснение:
Если ввод осуществляется через файл, то он должен называть "Слова.txt" и находиться в одной директории с исполняемым файлом. Выбрать нужный вариант ввода можно просто введя цифру в перовом input.
Код:
# -*- coding: utf-8 -*-
format = int(input("Считать слова из файла (введите 1)\nВводить слова в консоль (введите 2)\nВвести слова в одну строку(введите 3)\nВыбор: "))
words = []
answer = []
if format == 1:
f = open('Слова.txt', "r", encoding='utf-8')
line = f.readline()
while line:
for i in line.split(", "):
words.append(i)
line = f.readline()
f.close()
elif format == 2:
n = int(input("Введите кол-во слов - "))
for i in range(n):
words.append(input("Вв. слол - "))
elif format == 3:
n = input("Введите строку - ")
for i in n.split(", "):
words.append(i)
else:
print("Неправильно введен номер ответа")
word = input("Введите поисковое слово - ")
for i in words:
for j in list(word):
if len(set(word).intersection(set(i))) == len(i):
answer.append(i)
break
print(", ".join(answer))
Текст для документа:
рыба, рак, щука, лебедь, карась, пескарь, баня, бубен, столб, баян, барыня