Информатика, вопрос задал vovvova196 , 1 год назад

PYTHON

Задано дані про вік і стать кожної з n=5 осіб. Скласти програму, яка визначає загальну кількість чоловіків.

вік 34 стать чоловік
вік 42 стать жіноча
вік 37 стать чоловік
вік 29 стать жіноча
вік 32 стать жіноча

Ответы на вопрос

Ответил dimonchop
1

Відповідь:

# Initializing the variables

total_men = 0

# Iterating through the given data

for i in range(5):

   age = input("Enter the age of the person: ")

   gender = input("Enter the gender of the person (male/female): ")

   if gender == "male":

       total_men += 1

# Printing the result

print("The total number of men is:", total_men)

Новые вопросы