Courseiva

EX294 Transform data with filters and plugins Practice Question

Exhibit

Refer to the exhibit.
```yaml
- hosts: localhost
  tasks:
    - debug:
        msg: "{{ ['apple', 'banana'] | map('upper') | list | first }}"
```

What is the output of the following playbook task? ```yaml - name: Example task debug: msg: "{{ ['apple', 'banana'] | map('upper') | first }}" ```

⚠ Common exam trap

Watch out — candidates often think `map` returns a list directly, but it returns a generator, and they might also confuse the output format (single string vs. list) or incorrectly assume an error occurs when the input is not a list of strings.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

'APPLE'

The playbook task likely uses a filter that extracts only the first element after applying `map('upper')`. For example, `{{ ['apple', 'banana'] | map('upper') | first }}` would output 'APPLE'. The `map` filter applies the `upper` filter to each element, but the `first` filter selects only the first item, resulting in the string 'APPLE'. Candidates may mistakenly think the entire list is returned, but this task explicitly retrieves a single element.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    'APPLE'

    Why this is correct

    The `map('upper')` filter applies the upper filter to every element, yielding `['APPLE', 'BANANA']`, then `first` returns the initial element, `'APPLE'`. This satisfies the stem's requirement to evaluate the chained filters in sequence and report the resulting string output.

  • ✗

    An error because map expects a list of strings.

    Why it's wrong here

    The map filter applies the upper filter to each element of the list, and strings are valid input, so no error occurs. It is tempting because map does require an iterable, but a list of strings satisfies that; the filter returns ['APPLE', 'BANANA'], from which first yields 'APPLE'.

  • ✗

    ['APPLE', 'BANANA']

    Why it's wrong here

    The first filter returns a single element, not the whole list, so the uppercase list is reduced to its first item. It is tempting because map does produce ['APPLE', 'BANANA'], but first then extracts 'APPLE' from that result.

  • ✗

    'apple'

    Why it's wrong here

    The map filter transforms each element to uppercase before first selects an item, so the result is 'APPLE', not the original lowercase string. It is tempting because first returns the initial element, but that element has already passed through the upper filter.

About these practice questions

One of 392 original EX294 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This EX294 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX294 exam.