String Formats Flashcards

0
Q

%r

A

Repr format (debugging format).

…”%r” % int == “<type ‘int’>”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

%s

A

String format.

…”%s there” % ‘hi’ == ‘hi there’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

%c

A

Character format.

…”%c” % 34 == ‘ “ ‘

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

%d

A

Decimal integers (not floating point).

…”%d” % 45 == ‘45’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

%i

A

Decimal integers (not floating point).

…”%i” % 45 == ‘45’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

%u

A

Unsigned decimal.

…”%u” % -1000 == ‘-1000’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

%o

A

Octal number

…”%o” % 1000 == ‘1750’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

%x

A

Hexadecimal lower case.

…”%x” % 1000 == ‘3e8’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

%X

A

Hexadecimal upper case.

…”%X” % 1000 == ‘3E8’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

%e

A

Exponential notation, lower case ‘e’.

…”%e” % 1000 == ‘1.000000e+03’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

%E

A

Exponential notation, upper case ‘E’.

…”%E” % 1000 == ‘1.000000E+03’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

%f

A

Floating-point real number

…”%f” % 10.34 == ‘10.340000’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

%F

A

Floating point real number, same as ‘%f’.

…”%F” % 10.34 == ‘10.340000’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

%g

A

Either %e or %f, whichever is shorter

…”%g” % 10.34 == ‘10.34’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

%G

A

Floating-point E or F, whichever is shorter, same as ‘%g’

…”%G” % 10.34 == ‘10.34’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

%%

A

Percent sign

…”%g%%” % 10.34 == ‘10.34%’