NCP-GENL Prompt Engineering Practice Question
A developer is prompting an NVIDIA NIM for a Code Llama model to generate a Python function. The model produces correct logic but frequently omits type hints and docstrings, which the team requires. Which prompting technique best addresses this specific gap?
⚠ Common exam trap
The trap here is using subjective quality phrases like production-quality code instead of demonstrating the exact structural elements the model must include.
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
✓
Include a short example of the desired function signature, type hints, and docstring in the prompt, then ask for the new function in the same style.
A concrete example showing the desired function signature, type hints, and docstring teaches the model the exact format by imitation. Vague quality instructions, larger token budgets, and reasoning steps do not specify these structural requirements, so they fail to close the gap. The example-based approach is the most direct and reliable fix.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Include a short example of the desired function signature, type hints, and docstring in the prompt, then ask for the new function in the same style.
Why this is correct
Providing a concrete example that exhibits type hints and a docstring demonstrates the exact format expected. The model imitates the pattern it sees, so this one-shot demonstration directly fills the missing elements. It is more reliable than vague style instructions because the required structure is shown rather than described, leaving little room for interpretation.
- ✗
Increase max_tokens so the model has more room to include type hints and docstrings.
Why it's wrong here
max_tokens limits the maximum length of the completion; it does not encourage the model to add specific content. If the model is not inclined to include type hints, a larger budget will not change that. The omission is a behavioral issue, not a truncation issue, so expanding the budget does nothing here.
- ✗
Add the instruction "write clean, production-quality code" to the system message.
Why it's wrong here
This phrase is subjective and does not specify type hints or docstrings. Different developers interpret clean code differently, and the model may consider its output already clean. Without concrete examples or explicit requirements, the model has no signal that these two elements are mandatory, so the gap persists.
- ✗
Ask the model to first explain its reasoning about the function, then output the code.
Why it's wrong here
Reasoning about the function does not guarantee that type hints and docstrings appear in the final code. The model may reason correctly and still emit a bare function. The requirement is a formatting convention, so a demonstration or explicit checklist is needed; step-by-step reasoning addresses logic, not code style.
About these practice questions
One of 352 original NCP-GENL 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 →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official NVIDIA exam blueprint
This NCP-GENL practice question is part of Courseiva's free NVIDIA 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 NCP-GENL exam.