Formatters Flashcards
1
Q
%r
A
Used for debugging, it displays the “raw” data of the variable
Ex:
print “Man, this guy has %r watermelons! That’s a %r of watermelons.” % (23, lot)
Man, this guy has ‘23’ watermelons! That’s a ‘lot’ of watermelons.
2
Q
%s
A
Used for displaying strings
Ex:
print “Hello, %s!” % World
Hello, World!
3
Q
%d
A
Used for displaying numbers
Ex:
print “Hello, I am %d years old.” % 23
Hello, I am 23 years old.