Skip to content

Leap year

Python compound condition

Flowchart (ISO 5807)

YesNoStartInput yy mod 4 = 0 and (y mod 100≠ 0 or y mod 400 = 0)Return TrueEndReturn FalseEndFigure 1 — is_leap

Source code

Python
def is_leap(y):
    if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):
        return True
    return False

The editor opens with this code — change it and the chart redraws.

Language
Python
Constructs
compound condition
Topic
Branching
Formats
Word, Visio, draw.io, PDF, SVG

Related examples