Databricks Generative AI Engineer Associate exam dumps

Databricks Generative AI Engineer Associate practice question 196 of 306

Databricks Certified Generative AI Engineer Associate. Free level, Databricks. Free question with the correct answer and a full explanation.

Databricks Generative AI Engineer Associate Question 196

Single answer

You are tasked with building a simple chain in Databricks that processes user input through two functions: one that removes punctuation and another that converts the text to lowercase. The result should then be returned to the user. Which of the following code snippets correctly implements this chain?

  1. A

    def remove_punctuation(text): return ''.join(c for c in text if c.isalnum() or c.isspace())

    def to_lowercase(text): return text.lower()

    def process_input(user_input): return remove_punctuation(to_lowercase(user_input))

  2. B

    def remove_punctuation(text): return ''.join(c for c in text if c.isalnum() or c.isspace())

    def to_lowercase(text): return text.lower()

    def process_input(user_input): return to_lowercase(remove_punctuation(user_input))

  3. C

    def remove_punctuation(text): return ''.join(c for c in text if c.isalnum())

    def to_lowercase(text): return text.upper()

    def process_input(user_input): return to_lowercase(remove_punctuation(user_input))

  4. D

    def remove_punctuation(text): return ''.join(c for c in text if c.isalnum() or c.isspace())

    def to_lowercase(text): return text.lower()

    def process_input(user_input): return remove_punctuation(user_input) + to_lowercase(user_input)

Show answer and explanation

Correct answer: B

Explanation

The correct implementation of a chain ensures that the output of one function is correctly passed as the input to the next function. In this case, punctuation should be removed first, and then the resulting text should be converted to lowercase. Option 2 correctly implements this order and functionality.

  • A. Incorrect.

    This code incorrectly applies the remove_punctuation function after converting the text to lowercase, resulting in incorrect chaining behavior. The text should first have punctuation removed, then converted to lowercase.

  • B. Correct.

    This code correctly chains the functions by first removing punctuation, then converting the result to lowercase. This ensures the desired processing order.

  • C. Incorrect.

    This code incorrectly uses text.upper() instead of text.lower(), which violates the requirement to convert text to lowercase. Additionally, the remove_punctuation function improperly excludes spaces.

  • D. Incorrect.

    This code does not properly implement chaining. It processes the input separately with remove_punctuation and to_lowercase without passing the output of one function into the other, leading to incorrect results.

Timed practice exam

Take a Databricks Generative AI Engineer Associate practice test under exam conditions

45 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam