String Formats Flashcards

1
Q

%d

A

%d is used as a placeholder for numeric decimal values.

Outputs the number in base 10

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

%i

A

%i is used as a placeholder for numeric or decimal values.

Signed integer decimal.

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

%o

A

%o is used as a placeholder for Octal format.

Outputs the number in base 8.

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

%u

A

Obsolete type – it is identical to ‘d’.

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

%x

A

%x is used as a placeholder for Hex format
lowercase characters.
Outputs the number in base 16, using lower- case letters for the digits above 9.

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

%X

A

%X is used as a placeholder for Hex format
UPPERcase characters.
Outputs the number in base 16, using upper- case letters for the digits above 9.

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

%e

A

%E is used as a placeholder for Exponent notation.
Floating point exponential format (lowercase).
usually base power 10 or 2
An approx or undefined number, presented as a range of numbers which it can be taken from. This number will have a power/factor allocated to it usually base power 10 or 2

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

%E

A

%E is used as a placeholder for Exponent notation.
Floating point exponential format (uppercase).
Same as ‘e’ except it uses an upper case ‘E’ as the separator character.
An approx or undefined number, presented as a range of numbers which it can be taken from. This number will have a power/factor allocated to it usually base power 10 or 2

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

%f

A

%f is used as a placeholder for Fixed point. Displays the number as a fixed-point number. The default precision is 6.
A fixed decimal number with a power/factor usually base power 10 or 2

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

%F

A

%F is used as a placeholder for Fixed point. Same as ‘f’, but converts nan to NAN and inf to INF.
A fixed decimal number with a power/factor usually base power 10 or 2

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

%g

A

%g is used as a placeholder for Floating point format.
Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
An approx or undefined number, presented as a range of numbers which it can be taken from.

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

%G

A

%G is used as a placeholder for Floating point format.
Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
An approx or undefined number, presented as a range of numbers which it can be taken from.

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

%s

A

%s is used as a placeholder for string values you want inject into a formatted string.
Converts any non string to string using str()

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

%r

A

%r is used as a placeholder for an unspecified number or random number
i.e. when program requires user input for a number so does not know it yet
Converts any non string to string using repr()

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

%b

A

%b is used as a placeholder for Binary numeric values.

Outputs the number in base 2.

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

%c

A

%c is used as a placeholder for a Character. Converts the integer to the corresponding unicode character before printing.