Посмотрите код в Phyton, не могу вывести возраст, ответ должен быть 76 лет
print("Enter your name:")
name = "JOHN"
print(name.capitalize())
print("Enter your last name:")
lastname = "Doe"
print(lastname)
print("When were you born?:")
print("1945")
date_of_birth = datetime.strptime(input("2021"))
def calculate_age(born):
today = date.today(2021)
return today.year - born.year
age = calculate_age(date_of_birth)
print(age)
print("Where are you from?")
state = "canada"
print(state.capitalize())
message = "Hello, %s %s . You are %s years old. You are living in %s" % (name, lastname, age, state)
print(message)
Ответы
Ответ дал:
2
Ответ:
Попробуй:
print("Enter your name:")
name = "JOHN"
print(name.capitalize())
print("Enter your last name:")
lastname = "Doe"
print(lastname)
print("When were you born?:")
print("1945")
date_of_birth = 1945
def calculate_age(born):
return 2021 - born
age = calculate_age(date_of_birth)
print(age)
print("Where are you from?")
state = "canada"
print(state.capitalize())
message = "Hello, %s %s . You are %s years old. You are living in %s" % (name, lastname, age, state)
print(message)
Вас заинтересует
1 год назад
1 год назад
7 лет назад
7 лет назад