Format and Unicode Flashcards

1
Q

What are the libraries for formating, string-related formating, and dynamic formatting?

A
  • <format>
  • <string>
  • <string_view>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What arguments does the format() function take?

A
  • A format string
  • Any number of variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What characters represent variables in a format string?

A

{}

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

What is the syntax of a format function call given variables var1 and var2?

A

format(“{} {}”, var1, var2);

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

What is the syntax of all possible options to alter the format of a variable in a format function ‘{}’?

A

{argid : FillandAlign sign/#/0 width precision L type}

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

What is the width formatting option in a format() variable placeholder?

A

The number of characters wide that variable output will be.

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

Given string var1 = “1234567”, what is output from format(“”, var1);

A

“1234567”. The width formatting option will not truncate.

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

What is the syntax of the formatting option FillandAlign?

A

Ex: {:*<4} results in a width of 4, filled with * and left aligned.

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

If the formatting option FillandAlign, what are the alignment character options?

A
  • < Left alignment, fills chars AFTER data
  • > Right alignment, fills chars BEFORE data
  • ^ Center Aligned, tries to evenly split the fill characters, favoring left aligned.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In the FillandAlign formatting option, what is the one character that is disallowed?

A

’{}’

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

What are the options for “sign” in the format() function sign/#/0 flag?

A
  • ’+’, shows a + for nonnegative values
  • ’-‘ shows a sign only for negative values (default)
  • ’ ‘ inserts a leading space in nonnegative values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the options for the alternate form “#” in the format() function sign/#/0 flag?

A
  • 0b for binary
  • 0 for octal
  • 0x for hexadecimal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the “0” in the format() function sign/#/0 flag?

A

The option to insert preceding 0’s before the data. Equivalent to fillchar 0 right aligned. The 0 is ignored if the data is left aligned.

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

What is the precision flag in the format function?

A

The decimal precision of the output.

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

What is the format of the precision flag in the format function?

A

Ex: {.5} is 0.00000

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

What are nested format strings?

A

In the format string {}, additional {} characters can be used for additional variables. Ex:
format(“{:0{}.{}f}”,tau,10,5)

17
Q

In the format function what are the type flag options?

A
  • b/B binary
  • d decimal
  • o/x/X octal or hex. (Capital X Caps all hex characters)
  • nothing/s string
  • a/A hexfloat
  • f/F standard floating point
  • e/E scientific
18
Q

In the format function what is the L formatting flag?

A

Locale-specific formating; adds commas to arithmatic types

19
Q

In the format function what is the argid formatting flag?

A

It is the variable index to be used for the format string from the variables provided. Ex:
format(“{1:}”, 10, 20); results in 20.