I am a novice in ghpython and jsut started doing some tutorials. The one attached is where I got stuck at #16 of the script where it says

elif x%num1==0 or y%num2==0:

to my understanding this means if the x number of the loop is divided by num1 (in this case 6) and equals to 0, then append these points to pt2 variable. (same for y%num2)
The question is when the x values in the loop say when x=4 or 5, then 4%6=2,5%6=1 (pls correct me if I am wrong!!)
However, having said that, points x4, x5 are still being appeneded to pt2 (shown in red)
Please also see my mark up if it shows what I mean a bit better.

so can anyone guide me through as to why x4 and x5 are in list pt2 when Num1 is 6?
thank you so much!
regards

import rhinoscriptsyntax as rs
import Rhino.Geometry as gh
pt1=[]
pt2=[]
pt3=[]
for x in range(0,100,1):
for y in range(0,100,1):
pt=rs.AddPoint(x,y,0)
if x%num1==0 and y%num2==0:
pt1.append(pt)
elif x%num1==0 or y%num2==0: # but num1: 4%6=2,5%6=1
pt2.append(pt)
else:
pt3.append(pt)

import rhinoscriptsyntax as rs
import Rhino.Geometry as gh
pt1=[]
pt2=[]
pt3=[]
ptsX=[]
for x in range(0,xSize,1):
ptsY=[]
for y in range(0,ySize,1):
pt=rs.AddPoint(x,y,0)
if y==0:
ptsX.append(pt)
ptsY.append(pt)
if x%numX==0 and y%numY==0:
pt1.append(pt)
elif x%numX==0 or y%numY==0: # but num1: 4%6=2,5%6=1
pt2.append(pt)
else:
pt3.append(pt)

Or:

import rhinoscriptsyntax as rs
import Rhino.Geometry as gh
pt1=[]
pt2=[]
pt3=[]
ptsX=[]
ptsY=[]
for x in range(0,xSize,1):
for y in range(0,ySize,1):
pt=rs.AddPoint(x,y,0)
if x==0:
ptsY.append(pt)
if y==0:
ptsX.append(pt)
if x%numX==0 and y%numY==0:
pt1.append(pt)
elif x%numX==0 or y%numY==0: # but num1: 4%6=2,5%6=1
pt2.append(pt)
else:
pt3.append(pt)

Too early yet for my coffee but yours must have kicked in by now?

else if either condition is true

That’s “or” as opposed to “and” where both conditions must be true.

This is the same code, slightly refactored for readability: (though longer code isn’t necessarily easier to read!)

import rhinoscriptsyntax as rs
import Rhino.Geometry as gh
pts_White = []
pts_Red = []
pts_Black = []
# trace points
ptsX=[]
ptsY=[]
for x in range(0,xSize,1):
for y in range(0,ySize,1):
pt=rs.AddPoint(x,y,0)
X_evenly = x % numX == 0
Y_evenly = y % numY == 0
if X_evenly and Y_evenly:
pts_White.append(pt)
elif X_evenly or Y_evenly:
pts_Red.append(pt)
else:
pts_Black.append(pt)
# trace points
if x==0:
ptsY.append(pt)
if y==0:
ptsX.append(pt)

It’s kicking in now , so for example at the X axis where it marks 1, the reason why it is red is because the coordinate at that point is 1,0 (y is evenly) etc?