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