Format and Unicode Flashcards
What are the libraries for formating, string-related formating, and dynamic formatting?
- <format>
- <string>
- <string_view>
What arguments does the format() function take?
- A format string
- Any number of variables
What characters represent variables in a format string?
{}
What is the syntax of a format function call given variables var1 and var2?
format(“{} {}”, var1, var2);
What is the syntax of all possible options to alter the format of a variable in a format function ‘{}’?
{argid : FillandAlign sign/#/0 width precision L type}
What is the width formatting option in a format() variable placeholder?
The number of characters wide that variable output will be.
Given string var1 = “1234567”, what is output from format(“”, var1);
“1234567”. The width formatting option will not truncate.
What is the syntax of the formatting option FillandAlign?
Ex: {:*<4} results in a width of 4, filled with * and left aligned.
If the formatting option FillandAlign, what are the alignment character options?
- < Left alignment, fills chars AFTER data
- > Right alignment, fills chars BEFORE data
- ^ Center Aligned, tries to evenly split the fill characters, favoring left aligned.
In the FillandAlign formatting option, what is the one character that is disallowed?
’{}’
What are the options for “sign” in the format() function sign/#/0 flag?
- ’+’, shows a + for nonnegative values
- ’-‘ shows a sign only for negative values (default)
- ’ ‘ inserts a leading space in nonnegative values
What are the options for the alternate form “#” in the format() function sign/#/0 flag?
- 0b for binary
- 0 for octal
- 0x for hexadecimal
What is the “0” in the format() function sign/#/0 flag?
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.
What is the precision flag in the format function?
The decimal precision of the output.
What is the format of the precision flag in the format function?
Ex: {.5} is 0.00000