Question: (Closed) what is y%x == 0 in python
0
gravatar for mikysyc2016
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
ADD COMMENTlink 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.

ADD REPLYlink written 21 months ago by drkennetz470

This is not a bioinformatics-related question!

Hint: Try to Google modulus operator in Python.

ADD REPLYlink modified 21 months ago • written 21 months ago by Sej Modha4.6k

Hello mikysyc2016!

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

Hints already provided in comments.

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!

ADD REPLYlink modified 21 months ago • written 21 months ago by genomax78k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 630 users visited in the last hour