^

' '



Integer : d, b ,
o, x , X , C

=



float: e, E , f , F , g, G, %
 Signature and Delimiter Options

+

Signs are used for both positive and negative numbers



notation is only used for negative numbers ( default)


space
leading spaces for positive numbers and minus signs for negative numbers
, 
comma. Decimal Integers and Floating Points: Thousand Separator

_

underscore. Decimal Integers and Floating Points: Thousands Separator; b, o, x, and X Types: Every Four Digits Separator 

 Example: Symbols and Delimiters
#(+): add a sign to both positive and negative number
# sign (): sign is used only for negative numbers #Unsigned equals sign ()
f"{3:+} or {3:+}"

'+3 or 3 '


f"{3:} or {3: }"

'3 or 3'

#Symbol (space): The leading space of a positive number and Negative sign for negative numbers
# Symbol (+ ), delimiter(,)
f"{3} or {3}"

'3 or 3'

f"{3: } or {3: }"

'3 or 3'

f"{10000 :+,}"

'+10, 000'
 Sign Aware Padding
Use =Alignment Option
to force padding determined by the symbol to be placed ( Padding and width specifications after the number if any) but before the number. This is useful for number representations like "+000042". This alignment option is only available for number types.
0option
produces signaware zeropadding, Like the=alignment option padded with '0'. It is produced by prepending a '0' to the field width specification.
#fill(?), alignment(=), sign(+), width(5)
# full (0), alignment (=), sign (+), width (5)
f"{3:0=+5}"

'+0003'

# sign(+), 0option, width(5)
f"{3:+05}"

'+0003'

f"{3:05}"

'00003 '
# print symbols 3341 with unicode decimal representation
Integer representation type


d
Decimal Integer: Number in base 10
not any

n
number. Same as d , except that the current locale is used to set the appropriate number separator

f "binary: {i:#b }; octal: {i:#o}; hex: {i:#x} or {i:#X}"
b
Binary: A number in base 2.

o
Octal: A number in base 8.
i=13
# Represents decimal 13 in binary, octal and hexadecimal
f"binary: {i:b}; octal: {i:o}; hex: {i:x} or {i:X}"
x, X
Hexadecimal: a base 16 number. x and X for lowercase and uppercase for numbers> 9

C
Unicode characters. Convert decimal integer to corresponding unicode character
# option: use#  option to add prefix
#b : Add prefix 0b #o : Add prefix
0o
#x : add prefix 0x #X: add prefix 0X



'Binary: 1101; Octal: 15; Hexadecimal: d or D'


# returns the decimal representation unicode character 36
# fill (0), align (=), #option, width (8), type (b)
' Binary: 0b1101; Octal: 0o15; Hex: 0xd or 0XD'
# Binary file with prefix and zero padding

f"{i:#08b}"

'0b001101'
 

f"{36:c}" 

'$'

print(''.join([f"{x:c}" for x in range(33,42)]))



!"#$%&'()
# type d is the default value for integers, so no need
# delimiter (,) and class Type(d)

f"{10000:,d}"
 '10,000'

f"{10000:,}"
#Use the locale specific number format, set the locale
Import Locale
locale.setlocale(locale.LC_ALL, '')
# Then use format type 'n'
'10,000'

#Separator(_),Type(b)

F"{ 1200:_b}"
 '100_1011_0000 '

f"{106:n}"

'1,000,000'


Floating point representation type

type

Name

For a given precisionp ...

e, E
 Scientific notation  coefficients have 1 decimal point and p digits after the decimal point. # lowercase g and uppercase G f , F
 Fixedpoint notation  Yesp digits after the decimal point.  G , G
General format  round ds numbers are converted to p significant digits, and then according to the size in fixed point or Formatted in scientific notation.  % 
 percentage  Multiply the number by 100 and display it in fixed f format followed by a percent sign. The default value for floating point numbers is p=6. Default value in decimal. The decimal p is large enough to display all coefficient digits. Lowercase and uppercase: Make sure scientific notation is to display "e ' or 'E' ' and whether to use 'nan' versus 'NAN' and 'inf' versus 'INF'. Example: Simple floating point comparison # %style with precision=1 # lowercase e and uppercase E #lowercase f and uppercase F 
f"{1/2:.1 %}"
 '50.0 %'  f"{1000:.1e} with {1000:.1E}"  '1.0e+03 and 1.0E+03'  
f"{1000:.1f} and {1000:.1F}"  '1000.0 vs 1000.0' 
 
# Lowercase and uppercase NaN means F "{1000:.1g} and {1000:.1G}"  '1e+03 and 1E+03'  
nan=float('nan') f"{nan: f} vs {nan:F}" 
 







