Judging leap years. The user inputs a year, judges whether the year is a leap year, and outputs True and False respectively.
The year is a leap year when one of the following conditions is met:
(1) The year is a multiple of 4 Rather than a multiple of 100 (such as 2004 is, 1900 is not). (2) The year is a multiple of 400 (for example, it is in 2000 but not in 1900).
Complete program: stryear=input("Please enter the year:")
year=int(stryear)
Result=_____________________________________________________
print("The judgment result of a leap year is: "result)
+6Votes
result=True
if (((year%4==0) and (year%100!=0)) or year%400==0)
Else result=False
Just use if-else statement to achieve
+3Votes
“True” if (((year% 4 == 0) and (year% 100 != 0)) or year% 400 == 0) else “False”
+5Votes
The result is 25
+3Votes
result=(True if (((year%4==0) and (year%100!=0)) or year%400==0) else False)