Welcome Guest.


python solution

Asked by: Margaret Ward 185 views IT October 15, 2020

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:")



print("The judgment result of a leap year is: "result)

4 Answers

  1. +6Votes  


    if (((year%4==0) and (year%100!=0)) or year%400==0)

    Else result=False

    Just use if-else statement to achieve

    Gary Walker- October 15, 2020 |

  2. +3Votes  

    “True” if (((year% 4 == 0) and (year% 100 != 0)) or year% 400 == 0) else “False”

    Answer: The writing method of trinocular operation similar to C-like language mainly examined

    Michelle Reid- October 16, 2020 |

  3. +5Votes  

    The result is 25

    Raymond Collins- October 17, 2020 |

  4. +3Votes  

    result=(True if (((year%4==0) and (year%100!=0)) or year%400==0) else False)

    Teresa Rose- October 17, 2020 |