我正在尝试创建一个代码,要求用户提供他们的出生日期和今天的日期,以确定他们的年龄.到目前为止我写的是:
print("Your date of birth (mm dd yyyy)")
Date_of_birth = input("--->")
print("Today's date: (mm dd yyyy)")
Todays_date = input("--->")
from datetime import date
def calculate_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
age = calculate_age(Date_of_birth)
Run Code Online (Sandbox Code Playgroud)
然而它并没有像我希望的那样运行.有人可以向我解释我做错了什么吗?
11 % 14 == 11 and ( 6 * 3 // 4 > 4 or 20 // 6 != 3)
Run Code Online (Sandbox Code Playgroud)
当我在Python中键入它时,它告诉我该语句是错误的.
if 11 % 14 == 11 and ( 6 * 3 // 4 > 4 or 20 // 6 != 3):
print("True")
else:
print("False")
Run Code Online (Sandbox Code Playgroud)
从我的理解11%14 == 11是真的,6*3 = 18 // 4是4所以这是真的,20 // 6将是3所以这也应该是真的吗?有人可以向我解释它是如何错误的吗?