String Formatting

Let's say we want to represent "$1.50" properly from the calculation of 6 quarters into their currency total.

In [14]:
total = 54541.58364736783556875
print("The total value of your change is ${0:<20.2f}".format(total))
The total value of your change is $54541.58            
In [19]:
name = "Rich"
print("The total value of your change is {0}".format(name))
The total value of your change is Rich
In [ ]: