import random
import pickle


# 1
students = {"Лазарев": random.randint(1, 100),"Анисенков": random.randint(1, 100),"Филлипова": random.randint(1, 100),"Филлипов": random.randint(1, 100),"Жалнин": random.randint(1, 100),"Махнов": random.randint(1, 100),"Лыкова": random.randint(1, 100),"Терехов": random.randint(1, 100),"Голощапов": random.randint(1, 100),"Мельников": random.randint(1, 100)}
print("Исходный словарь")
for stud, zeloe in students.items():
    print(f"Студент {stud} - {zeloe}")

# 2
with open('stud.txt', 'wb') as f:
    pickle.dump(students, f)

# 3
del students

# 4
with open('stud.txt', 'rb') as f:
    students = pickle.load(f)
if students:
    keys = list(students.keys())
    students.pop(keys[0])
    students.pop(keys[-1])

# 5
print("Новый словарь")
for stud, zeloe in students.items():
    print(f"Студент {stud} : {zeloe}")
