Files
operators/operators_33.py
2025-12-11 18:06:09 +05:00

48 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
def get_experience(employee):
return employee[4]
n = int(input("Введите количество сотрудников: "))
employees = []
for i in range(n):
data = input(f"Введите данные сотрудника {i + 1} (Фамилия Имя Отчество Пол Стаж): ").split()
employee = [data[0], data[1], data[2], data[3], int(data[4])]
employees.append(employee)
sorted_by_experience = sorted(employees, key=get_experience)
youngest = sorted_by_experience[0]
oldest = sorted_by_experience[-1]
print(f"\nСамый молодой сотрудник (по стажу): {youngest[0]} {youngest[1]} {youngest[2]}, стаж: {youngest[4]} лет")
print(f"Самый старый сотрудник (по стажу): {oldest[0]} {oldest[1]} {oldest[2]}, стаж: {oldest[4]} лет")
men = []
women = []
for employee in employees:
if employee[3] == "М":
men.append(employee)
else:
women.append(employee)
k = input("\nВведите букву для поиска: ")
men_count = 0
for man in men:
if man[1][0].lower() == k.lower():
men_count += 1
women_count = 0
for woman in women:
if woman[1][0].lower() == k.lower():
women_count += 1
print(f"\nМужчин с именем на '{k}': {men_count}")
print(f"Женщин с именем на '{k}': {women_count}")
if men_count > women_count:
print("Больше имен на эту букву у мужчин")
elif women_count > men_count:
print("Больше имен на эту букву у женщин")
else:
print("Одинаковое количество имен на эту букву")