Question: (Closed) what is y%x == 0 in python
0
21 months ago by
mikysyc201670
mikysyc201670 wrote:
``````>>> for y in range(2,N):
...      for x in range(2,y):
...           if y%x == 0:
...              print(y,'equals',x,'*',y//x)
...              break
``````

Do not understand " y%x " Thanks!

software error • 431 views
modified 21 months ago by WouterDeCoster43k • written 21 months ago by mikysyc201670
1

This is not a software error and I think this could be solved pretty quickly with a google search!

This is a modulus in python and returns the remainder of a division. Your code is saying if y/x has no remainder, do something.

a quick example of modulus: 3%1 returns 0 because 3/1 has no remainder, 3 is divisible by 1. 3%2 returns 1 because 3/2 has a remainder of 1.

This is not a bioinformatics-related question!

Hint: Try to Google modulus operator in Python.

Hello mikysyc2016!

We believe that this post does not fit the main topic of this site.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!