输入某年某年某月某日,判断这一天是这一年的第几天?思路:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于3时需考虑多加一天:year = int(input(‘year:’))month = int(input(‘month:’))day = int(input(‘day:’))months = [0,31,59,90,120,151,181,2
A: (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0))
B: (year % 400 = 0) or ((year % 4 = 0) and (year % 100 != 0))
C: (year % 400 == 0) and ((year % 4 == 0) and (year % 100 != 0))
D: (year % 400 == 0) and ((year % 4 == 0) or (year % 100 != 0))
A: (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0))
B: (year % 400 = 0) or ((year % 4 = 0) and (year % 100 != 0))
C: (year % 400 == 0) and ((year % 4 == 0) and (year % 100 != 0))
D: (year % 400 == 0) and ((year % 4 == 0) or (year % 100 != 0))
举一反三
- 题:(拓展)下面哪些表达式能够判断某年year不是闰年。 A: not(( year%4==0 and year%100 !=0 ) or ( year%400==0 )) B: not( year%4==0 and year%100 !=0 ) and not ( year%400==0 ) C: year%4!=0 or year%100 ==0 and ( year%400 !=0 ) D: year%4==0 and year%100 !=0 or ( year%400==0 )
- 判定year是否为闰年的表达式是 A: year % 400 == 0 or year % 4 == 0 and year % 100 <> 0 B: year % 400 == 0 or year % 4 == 0 , year % 100 != 0 C: year % 400 == 0 or year % 4 == 0 and year % 100 != 0 D: year % 400 == 0 or year % 4 == 0 , year % 100 <> 0
- 判断某年是否为闰年的表达式正确的是()。 A: year%4==0&&year%100!=0||year%400==0 B: year%4==0&&year%100=0||year%400!=0 C: year%4!=0&&year%100!=0||year%400==0 D: year%4==0&&year%100==0||year%400==0
- 使用变量year代表年份,以下表示判断year是否为闰年的布尔表达式是 。 A: (year % 4 == 0) and (not(year % 100 == 0)) or (year % 400 == 0) B: (year % 4 == 0) and (not(year % 400 == 0)) or (year % 100 == 0) C: (year % 4 == 0) and (year % 100 == 0) or (year % 400 == 0) D: (year % 4 == 0) or (not(year % 100 == 0)) and (year % 400 == 0)
- 已知判断某年year是闰年的条件是满足下列二者之一(1)能被4整除,但不能被100整除(2)能被400整除下面哪个逻辑表达式可作为year是闰年的判断条件? A: ((year%4==0) || (year%100!=0)) && (year%400==0) B: ((year%4=0) || (year%100!=0)) && (year%400=0) C: ((year%4==0) && (year%100!=0)) || (year%400==0) D: ((year%4=0) && (year%100!=0)) || (year%400=0)