What is the Purpose of the Part in Quotes


#1

def power(base, exponent):
result = base**exponent
print "%d to the power of %d is %d." % (base, exponent, result)

power(37,04)

What is the purpose of this section below to making the code work?
"%d to the power of %d is %d."

`


#2

It serves no purpose in the actual code, being only formatted output of the result.

The string output unit should be coming up soon. You might hear of this as being modulo formatting or string interpolation. The modulo (or percentage) character symbolizes a placeholder for an external object. The letter describes the type of expected argument data. d stands for digits, such as integers. s is string type, f is float type, and so on.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.