I am trying to understand the % operator fully.
It is used in mathematical functions to return the remainder of a division. i.e
5 % 2
It is also used to "inject" text into strings. i.e
string_1 = "Camelot"
string_2 = "place"
print "Let's not go to %s. 'Tis a silly %s." % (string_1, string_2)
Let's not go to Camelot. 'Tis a silly place.
I was wondering if the % operator, at the lower level, carries out different functions depending on whether it's interacting with a mathematical function or a string?
Or whether it does the same thing regardless of whether it's interacting with a mathematical function or a string, and there's some underlying functionality/concept which allows the operator to treat both scenarios the same way and return the expected result regardless?
My apologies if the question is hard to understand, I don't know how to ask this in simpler terms