Предмет: Информатика, автор: dbyrcv

1. Напишите программу, которая запрашивает фамилии студентов и их почтовые адреса, записывает полученные данные в файл "номер_группы.txt" и выводит список из файла на экран (Решение этой задачи может быть разным: самое простое - организовать ввод и запись данных по одной строке, более сложный вариант - организовать цикл из нескольких итераций, их количество можно уточнять у пользователя: "Сколько строк данных Вы хотите ввести?" или спрашивать после ввода одной строки: "Ввести еще данные?" и т.п. Здесь можно решить любым способом, который Вам понятен на данном этапе изучения языка).
Язык Питон

Ответы

Автор ответа: bettapy
1

Ответ:

num = input('Введите номер группы: ')

while True:

   command = input('Ввести данные?\n(y/n) ')

   if command == 'y':

       surname = input('Введите фамилию: ')

       email = input('Введите почту: ')

       if input('Внести данные?\n(y/n) ') == 'y':

           with open(f'{num}.txt', mode='a', encoding='utf-8') as f:

               f.write(f'{surname} - {email}')

           print('Данные записаны')

       else:

           print('Запись данных отменена')

   else:

       print('Выход...')

       break

with open(f'{num}.txt', mode='r', encoding='utf-8') as f:

   data = f.read()

print('Фамилия - Почта')

print(data)

Вроде как вполне работает

Приложения:

bettapy: Вообще можно через .csv или .db/.sqlite сделать БД
Похожие вопросы
Предмет: Английский язык, автор: akhmathanov2016
Помогите задать 15 вопросов к тексту по Английскому языку.
Общий, Разделительный, Альтернативный, Специальный


American society seems to be much more informal than the British and, in some ways, is characterized by less social distinction. Students do not rise when a teacher enters the room. One does not always address a person by his title, such as "Major" or "General" or "Doctor" in the case of a holder of a Doctor of Philosophy degree. The respectful "Sir" is not always used in the northern and western parts of the country.
However, it is best to use a person's title when first meeting him/her, and then allow the person to tell you how he/she wishes to be called.
They use first names when calling each other, slap on the back, joke and are much freer in their speech, which is more slangy than the conventional British English. You will often hear the word "Hi" (a form of greeting among friends) used instead of the usual "Hello," and "Howdy" instead of "How do you do?"
Yet, in spite of all the informality, Americans, even in the way they address each other, show consciousness of social distinction. For example, one is likely to use somewhat more formal language when talking to superiors. While the informal "Hello" is an acceptable greeting from employee to employer, the employee is more apt to say "Hello, Mr. Ferguson," while the employer may reply "Hello, Jim."
Certain other forms of politeness are observed on social occasions. Women may wear hats in church. in restaurants, and often when attending luncheons in public places and other public social functions except those that take place in the evening.
Предмет: Математика, автор: зарница55