# Extracts a collection of birth dates from the user and determines# if each individual is at least 21 years of age.from date import Datedef main():# Date before which a person must have been born to be 21 or older.bornBefore = Date(6, 1, 1988)# Extract birth dates from the user and determine if 21 or older.date = promptAndExtractDate()while date is not None :if date <= bornBefore :print( "Is at least 21 years of age: ", date )date = promptAndExtractDate()# Prompts for and extracts the Gregorian date components. Returns a# Date object or None when the user has finished entering dates.def promptAndExtractDate():print( "Enter a birth date." )month = int( input("month (0 to quit): ") )if month == 0 :return Noneelse :day = int( input("day: ") )year = int( input("year: ") )return Date( month, day, year )# Call the main routine.main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。