Question about some Code-Signs

I’m looking at some Code examples.

In the API documentation I can’t find anything about the following signs in a Codeline:

for poly in me.polygons:
    print("Polygon index: %d, length: %d" % (poly.index, poly.loop_total))

What does that “%d” do ?


for f in me.faces:         
    f.material_index = f.index % 3

What kind of Operation (if it is any) is this “%” ?

Kind regards

those are standard-python questions, not actually about Blender.

% in strings are used for string formatting:

“Value: %d” % 12

%d is for signed integers

On numbers, % is the mathematical operation “modulo”:

Thanks for the link to the Python Documentation.
Sorry for asking such basics, I think I will find there the answer for some other basic questions as well.

Kind regards

You’re welcome. The python docs are good, but for learning there are probably better places which are less overwhelming and didactically edited. There are several threads with links about such learning resources around here.