If it has not been defined then it can't be interacted with. Python isn't supernatural. Something else is happening.
"%d squared is %d." % (n, squared)
is equivalent to:
"%d squared is %d.".__mod__((n, squared))
All of that is defined, what are you referring to, the d's? Those are in a string, they are just text.
operators are just convenient aliases to methods. Those methods then do whatever they want. Let's make % print meow.
def __mod__(self, other):
Derp() % 4
__mod__ for string thus looks for format specifiers and replaces them with the values that you supplied as arguments, doing so in different ways based on what the format specifier was. For example,
%d will make it convert the value to int and then the int to str with a base10 (decimal) representation