Question 1180
An engineer tests the parseint behavior in terraform console. What is the result of parseint("ff", 16)?
- 16
- 15
- 255
- "ff"
Explanation
Correct Answer
C:Evaluating the actual call parseint("ff", 16): In hexadecimal, each f digit represents fifteen; ff equals fifteen times sixteen plus fifteen, or 255.
Incorrect Answers
A:Given the specific operands supplied to the Terraform expression parseint("ff", 16), sixteen specifies the input base rather than the parsed integer.
B:Given the specific operands supplied to the Terraform expression parseint("ff", 16), fifteen is the value of one hexadecimal f, but this input has two digits.
D:Given the specific operands supplied to the Terraform expression parseint("ff", 16), parseint converts to a number instead of preserving the source string.
Question 1181
A Terraform 1.12 configuration evaluates element(flatten([["red", "green"], [], ["blue"]]), 4). Which result follows from the expression as written?
- "green:extra"
- "green"
- "red"
- "blue"
Explanation
Correct Answer
B:For the specific expression element(flatten([["red", "green"], [], ["blue"]]), 4), First, flatten traverses inner lists while empty inner lists contribute nothing; The list has 3 entries, so element wraps index 4 modulo 3 and selects zero-based position one.
Incorrect Answers
A:The extra text is not generated by element(flatten([["red", "green"], [], ["blue"]]), 4), because the final operation substitutes only the literal list members and format placeholders that are actually present.
C:For the concrete expression element(flatten([["red", "green"], [], ["blue"]]), 4), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
D:For the concrete expression element(flatten([["red", "green"], [], ["blue"]]), 4), the final list member is not selected; the effective index is one; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
Question 1182
For Terraform string processing with format each paired element, evaluate formatlist("%s-%d", ["app", "db"], [1, 2]). Which output is correct?
- ["app-1", "db-2"]
- ["app-2", "db-1"]
- ["app", "db"]
- ["app-1", "db-1"]
Explanation
Correct Answer
A:Evaluating the actual call formatlist("%s-%d", ["app", "db"], [1, 2]): formatlist applies its format template positionwise: app pairs with one, and db pairs with two.
Incorrect Answers
B:Given the specific operands supplied to the Terraform expression formatlist("%s-%d", ["app", "db"], [1, 2]), this crosses the numeric values between positions, although the input lists are paired by index.
C:Given the specific operands supplied to the Terraform expression formatlist("%s-%d", ["app", "db"], [1, 2]), this omits the numeric suffixes required by the format template.
D:Given the specific operands supplied to the Terraform expression formatlist("%s-%d", ["app", "db"], [1, 2]), the second numeric input is two, so db must be paired with two rather than one.
Question 1183
A Terraform 1.12 configuration evaluates slice(flatten([["red", "green"], [], ["blue"]]), 1, 3). Which result follows from the expression as written?
- ["red", "green", "blue"]
- ["red", "green"]
- ["blue", "green"]
- ["green", "blue"]
Explanation
Correct Answer
D:For the specific expression slice(flatten([["red", "green"], [], ["blue"]]), 1, 3), First, flatten traverses inner lists while empty inner lists contribute nothing; slice begins at zero-based index one and continues through the final member, stopping before the exclusive end index 3.
Incorrect Answers
A:For the concrete expression slice(flatten([["red", "green"], [], ["blue"]]), 1, 3), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
B:For the concrete expression slice(flatten([["red", "green"], [], ["blue"]]), 1, 3), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
C:For the concrete expression slice(flatten([["red", "green"], [], ["blue"]]), 1, 3), slice preserves order rather than reversing the extracted portion; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
Question 1184
A Terraform 1.12 configuration evaluates format("primary=%s", element(flatten([["red", "green"], [], ["blue"]]), 0)). Which result follows from the expression as written?
- "primary=red"
- "primary=green"
- "red"
- "secondary=red"
Explanation
Correct Answer
A:For the specific expression format("primary=%s", element(flatten([["red", "green"], [], ["blue"]]), 0)), First, flatten traverses inner lists while empty inner lists contribute nothing; element at zero selects the first member, and the single %s placeholder in format substitutes that member after the literal primary= prefix.
Incorrect Answers
B:For the concrete expression format("primary=%s", element(flatten([["red", "green"], [], ["blue"]]), 0)), this uses the second list element; element at index zero selects the first value; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
C:For the concrete expression format("primary=%s", element(flatten([["red", "green"], [], ["blue"]]), 0)), the format string has a literal primary= prefix that must appear in the result; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
D:For the concrete expression format("primary=%s", element(flatten([["red", "green"], [], ["blue"]]), 0)), the prefix is specified literally as primary= rather than secondary=; the inner stage produces ["red", "green", "blue"] before the outer operation is applied.
Question 1185
A Terraform 1.12 configuration evaluates length([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]). Which result follows from the expression as written?
- 5
- 2
- 4
- 0
Explanation
Correct Answer
B:For the specific expression length([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), First, the if filter discards beta before transforming the longer values to uppercase; that produces exactly 2 elements; The outer length call counts those resulting elements rather than the original textual arguments.
Incorrect Answers
A:In the calculation length([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), 5 is not the size of the evaluated collection: the inner result has 2 elements, and length counts precisely those elements.
C:For the concrete expression length([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), the inner collection has 2 values, not 4; length counts the resulting collection only; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
D:For the concrete expression length([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), the inner expression is not empty: it produces 2 elements; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
Question 1186
A Terraform 1.12 configuration evaluates join("/", [for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]). Which result follows from the expression as written?
- "GAMMA/ALPHA"
- "ALPHA/GAMMA/GAMMA"
- "ALPHA/GAMMA"
- "ALPHAGAMMA"
Explanation
Correct Answer
C:For the specific expression join("/", [for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), First, the if filter discards beta before transforming the longer values to uppercase; The outer join uses a slash only between consecutive list members and preserves their computed order.
Incorrect Answers
A:For the concrete expression join("/", [for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), this reverses the members even though join preserves the order returned by the inner expression; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
B:For the concrete expression join("/", [for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), join must not repeat the last item after the list has been joined; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
D:For the concrete expression join("/", [for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), this omits the slash delimiters requested by join; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
Question 1187
A Terraform 1.12 configuration evaluates reverse([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]). Which result follows from the expression as written?
- ["ALPHA", "GAMMA"]
- ["GAMMA"]
- []
- ["GAMMA", "ALPHA"]
Explanation
Correct Answer
D:For the specific expression reverse([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), First, the if filter discards beta before transforming the longer values to uppercase; reverse then returns the exact opposite element order, without sorting or removing members.
Incorrect Answers
A:For the concrete expression reverse([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), this leaves the inner result unchanged and skips the outer reverse call; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
B:For the concrete expression reverse([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), the reverse function does not discard an element of the input list; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
C:For the concrete expression reverse([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), reversing a nonempty list does not create an empty list; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
Question 1188
A Terraform 1.12 configuration evaluates sort([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]). Which result follows from the expression as written?
- ["ALPHA", "GAMMA"]
- ["GAMMA", "ALPHA"]
- ["ALPHA"]
- []
Explanation
Correct Answer
A:For the specific expression sort([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), First, the if filter discards beta before transforming the longer values to uppercase; Terraform sort then compares the resulting strings lexicographically in ascending order; it neither drops values nor preserves a non-sorted arrangement.
Incorrect Answers
B:For the concrete expression sort([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), a reversal is not guaranteed to produce ascending lexical order; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
C:For the concrete expression sort([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), sorting does not remove the final element of the list; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
D:For the concrete expression sort([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4]), the outer sort does not empty the nonempty collection; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
Question 1189
A Terraform 1.12 configuration evaluates element([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 3). Which result follows from the expression as written?
- null
- "GAMMA"
- "ALPHA"
- "index out of range"
Explanation
Correct Answer
B:For the specific expression element([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 3), First, the if filter discards beta before transforming the longer values to uppercase; The list has 2 entries, so element wraps index 3 modulo 2 and selects zero-based position one.
Incorrect Answers
A:For the concrete expression element([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 3), element returns a known string from this nonempty computed list, not a null result; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
C:For the concrete expression element([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 3), index wraparound lands at position one, not the first position of the inner list; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
D:For the concrete expression element([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 3), element wraps a positive index instead of failing like ordinary square-bracket indexing; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
Question 1190
A Terraform 1.12 configuration evaluates slice([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 1, 2). Which result follows from the expression as written?
- ["ALPHA"]
- []
- ["GAMMA"]
- ["ALPHA", "GAMMA"]
Explanation
Correct Answer
C:For the specific expression slice([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 1, 2), First, the if filter discards beta before transforming the longer values to uppercase; slice begins at zero-based index one and continues through the final member, stopping before the exclusive end index 2.
Incorrect Answers
A:For the concrete expression slice([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 1, 2), this takes an initial prefix rather than starting with the second entry; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
B:For the concrete expression slice([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 1, 2), the final end index is exclusive, but the last element still lies before that boundary; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.
D:For the concrete expression slice([for s in ["alpha", "beta", "gamma"] : upper(s) if length(s) > 4], 1, 2), this incorrectly keeps the first list member, although the slice begins at index one; the inner stage produces ["ALPHA", "GAMMA"] before the outer operation is applied.