NCP-GENL Prompt Engineering Practice Question
A data scientist is using an NVIDIA NeMo LLM to generate Python code from natural language descriptions. The model often produces code that works but does not follow the team's style guide, such as using single quotes instead of double quotes and missing type hints. Which prompt engineering technique should the data scientist use to improve adherence to the style guide?
⚠ Common exam trap
The trap here is assuming that a detailed zero-shot instruction is sufficient to enforce style, when in fact models often require concrete examples to reliably follow formatting rules.
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
✓
Few-shot prompting with examples that demonstrate the desired coding style.
Few-shot prompting with examples that embody the desired style guide is the most effective way to teach the model the specific formatting rules. By showing the model correct examples, it can mimic the style in new generations. This technique is particularly useful for coding tasks where precise syntax and style matter.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Chain-of-thought prompting to encourage the model to reason about the style guide before writing code.
Why it's wrong here
Chain-of-thought is useful for complex reasoning tasks, but it does not directly enforce output formatting. The model might reason about style but still produce code that deviates. For style adherence, explicit examples are more effective than reasoning steps, which can introduce variability.
- ✓
Few-shot prompting with examples that demonstrate the desired coding style.
Why this is correct
Few-shot prompting provides the model with concrete examples of the desired output style, such as double quotes and type hints. By including a few input-output pairs in the prompt, the model can infer the pattern and apply it to new queries. This is a standard prompt engineering technique to guide formatting and style without retraining.
- ✗
Zero-shot prompting with a detailed instruction describing the style guide rules.
Why it's wrong here
While zero-shot prompting with detailed instructions can help, it is often less effective than few-shot for style adherence. The model may still miss specific formatting details. In practice, providing examples is more reliable for enforcing consistent style, especially for nuanced rules like type hints and quote preferences.
- ✗
Increasing the temperature to allow more creative code generation.
Why it's wrong here
Higher temperature increases randomness, which would likely worsen style adherence. The goal is to constrain the model to a specific style, so lower temperature and few-shot examples are preferable. Creative generation is counterproductive when consistency is required.
About these practice questions
Courseiva writes every NCP-GENL question from scratch — 352 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.