Practice Makes Perfect


#1

Why does the program recognize "if number % 3 == 0" as correct? Only 0/3=0 so shouldn't the correct answer be "if number % 3 == int()"?


#2

Can you explain to me how you think the modulo operator (%) works? So i can confirm my theory, that indeed there is the problem

that last one doesn't make much sense, int() is a function to convert to integer


#3

I think that the % operator is the divisor symbol. In this case, its dividing number by 3 right?


#4

so, if % is division operator, then by your logic:

14 % 3

will output 4.6667, or 4 (given python rounds down)

but / is the division operator, % calculates the remainder (for 14 % 3, this would be 2, 12 is the biggest possible division, so there is two remaining)

the modulo operator is useful to check if a number is divisible by the divider, because the remainder equals zero


#5

I see. Thanks for correcting me and providing me with the new info! :slight_smile:


#6

all sorted out now?


#7

Yep thanks to your help! :grinning:


#8