I'm doing some basis conditional exercises, and I don't know what the % numbers mean in this code

Question:

currentYear = int(input('Enter the year: '))
month = int(input('Enter the month: '))
if ((currentYear % 4) == 0 and (currentYear % 100) != 0 or (currentYear % 400) ==0):
       print('Leap Year')

I have no idea what the % numbers in the brackets with the currentYear means. I gather it has something to do with leap years, but how does it become %4, %100 or %400?

I don’t know what this is all about to be honest…

Answers:

The % symbol in Python is called the Modulo Operator. It returns the remainder of dividing the left hand operand by right hand operand. It’s used to get the remainder of a division problem.

So 100 % 5 == 0

or

100 % 3 == 1 —> Remainder equals 1

Answered By: Lamar Mccloud
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.