Determining if a number evenly divides by 25, Python

I am trying to check if the number in the list is evenly equal to 25 using Python. I am not sure which is the right process. I want to do something like this:

n = [100, 101, 102, 125, 355, 275, 435, 134, 78, 550] for row in rows: if n / 25 == an evenly divisble number: row.STATUS = "Major" else: row.STATUS = "Minor" 

Any suggestions are welcome.

+6
source share
2 answers

Use the modulo operator :

 for row in rows: if n % 25: row.STATUS = "Minor" else: row.STATUS = "Major" 

or

 for row in rows: row.STATUS = "Minor" if n % 25 else "Major" 

n % 25 means "Give me the remainder when n is divided by 25 "

Since 0 is False y, you do not need to explicitly compare with 0 , just use it directly in if - if the remainder is 0 , then this is a large string, If it is not, this is a small string.

+15
source

Use the modulo operator to determine the remainder of the division:

 if n % 25 == 0: 
+12
source

Source: https://habr.com/ru/post/912435/


All Articles