Old Style String Formats Flashcards
(16 cards)
%d
Decimal Integers (not floating points)
“%d” %15 == “15”
%i
same as %d
%o
Octal number
“%o” %1000 == ‘1750”
%u
Unsigned Decimal
“%u% %-1000 == ‘-1000’
%x
Hexadecimal Lowercase
“%x” %1000 == ‘3e8’
%X
Hexadecimal Uppercase
“%x” %1000 == ‘3E8’
%e
Exponential notation, lowercase e
“%e” %1000 == ‘1.000000 + 03”
%E
Exponential notation, uppercase e
“%e” %1000 == ‘1.0000
%f
Floating point real number
“%f” %10.34 == ‘10.34000’
%F
Floating point real number
“%f” %10.34 == ‘10.34000’
%g
Either %f or %e, whichever is shorter
“%g” %10.34 == “10.34”
%G
Either %f or %e, whichever is shorter
“%g” %10.34 == “10.34”
%c
Character Format
“%c” %34 == ‘ “ ‘
%r
Repr format(debugging format)
“%r” %int == “”
%s
String Format
“%s there” %”hi” == “hi there”
%%
A percent sign
“%g%%” %10.34 == ‘10.34%’