examples/strings/formatted_string.py
#!/usr/bin/env python
from __future__ import print_function, division

name = "Foo Bar"

print("{:s}".format(name))
print("{}".format(name))
examples/strings/formatted_number.py
#!/usr/bin/env python
from __future__ import print_function, division

x = 42

print("{:b}".format(x)) #  binary:    101010
print("{:c}".format(x)) #  character: *
print("{:d}".format(x)) #  decimal:   42      (default)
print("{:o}".format(x)) #  octal:     52
print("{:x}".format(x)) #  hexa:      2a
print("{:X}".format(x)) #  hexa:      2A
print("{:n}".format(x)) #  number:    42


print("{}".format(x))   # defaults to decimal
examples/strings/formatted_float.py
#!/usr/bin/env python
from __future__ import print_function, division

x = 412.345678901

print("{:e}".format(x)) #  exponent:     4.123457e+02
print("{:E}".format(x)) #  Exponent:     4.123457E+02
print("{:f}".format(x)) #  fixed point:  412.345679 (default precision is 6)
print("{:F}".format(x)) #  same as f.    412.345679
print("{:g}".format(x)) #  generic:      412.346    (default precision is 6)
print("{:G}".format(x)) #  generic:      412.346
print("{:n}".format(x)) #  number:       4412.346


print("{}".format(x))   # defaults to g  412.345678901