0
这和我最后一个问题很相似。但在这里我想知道如何知道一个人是否可以做点什么,例如:如何验证生日是否通过?
如果joe小于21,他不允许喝酒,用生日告诉你他是否可以或不能。不使用导入或日历,试图得到它的挂钩
到目前为止,这是我想出的。
dateStr = input("Today's Date: ")
monthStr, dayStr, yearStr = dateStr.split("/")
months = ["January", "February","March", "April", "May", "June", "July", "August","September","October", "November","December"]
monthStr = months[int(monthStr)- 1]
print ("The converted date is:", monthStr, dayStr+",", yearStr)
print("Joe did NOT have his birthday this year!")
Joe's birthday = True
for chr in dateStr:
tv = True
if:
(i<= 13)
print("Joe is Not allowed to watch TV.")
else:
print("Joe is allowed to watch TV.")
driving = True
if:
(i<= 16)
print("Joe is NOT Allowed to drive")
else:
print("Joe is allowed to drive")
drinking = True
if:
(i<= 21)
print("Joe is NOT allowed to drink.")
else:
print("Joes is allowed to drink.")
人们可能会将生日转换为时间戳,并将其与时间戳进行比较,并将其与X年的秒数进行比较。 –