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年的秒數進行比較。 –