[Python] Determine leap years

Covers the points that beginners should hold

As a program written by beginners I often see fizzbuzz problems that output multiples of 3 and 5 For beginners to learn if statements, variables, comparison operators, types, etc. As a more practical and practical program, I think the leap year judgment is perfect.

leap.py


year_str = input("Enter 4 digits in the Christian era")
year = int(year_str)

if year % 100 == 0 and year % 400 != 0:
    print("It's normal")
elif year % 4 == 0:
    print("Leap year")
else:
    print("It's normal")

Also, Python needs to be careful about indentation.

Recommended Posts

[Python] Determine leap years
Determine prime numbers with python
Program to determine leap year from the Christian era [Python]
Get Leap Motion data in Python.
Python
Try using Leap Motion in Python
paiza coding skill check (seeking leap years)
Dealing with "years and months" in Python
Algorithm learned with Python 6th: Leap year