f string formatting

Integer

f'{value:width}'

where:

   value     is any expression that evaluates to a number

   width     specified the number of characters used in total to display, but if a value
             needs more space that the width specified then more space is used
abc = 100

print(f'{abc:12}')
print(f'{abc:<12}')
print(f'{abc:>12}')

Float

f'{value:width.precisionf}'

where:

   value     is any expression that evaluates to a number

  width      specified the number of characters used in total to display, but if a value
             needs more space that the width specified then more space is used

  precision  indicates the number of characters after the decimal point
abc = 10.0/3.0

print(f'{abc:12.4}')
print(f'{abc:<12.4f}')
print(f'{abc:>12.4f}')

Left or Right Justification

f'{value:>width}'
f'{value:<width}'

where:

   value     is any expression that evaluates to a number

   width     specified the number of characters used in total to display, but if a value
             needs more space that the width specified then more space is used.

Syntax

Syntax: "{" [field_name] ["!" conversion] [":" format_spec] "}"

# let's understand what each field means...
    field_name        ::=  arg_name ("." attribute_name | "[" element_index "]")*
    arg_name          ::=  [identifier | digit+]
    attribute_name    ::=  identifier
    element_index     ::=  digit+ | index_string
    index_string      ::=  <any source character except "]"> +
    conversion        ::=  "r" | "s" | "a"
    format_spec       ::=  [[fill]align][sign][#][0][width][grouping_option][.precision][type]

            # Looking at the underlying fields under format_spec...
            fill            ::=  <any character>
            align           ::=  "<" | ">" | "=" | "^"
            sign            ::=  "+" | "-" | " "
            width           ::=  digit+
            grouping_option ::=  "_" | ","
            precision       ::=  digit+
            type            ::=  "b" | "c" | "d" | "e" | "E" | "f" | "F" | 
                                 "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"