Chapter 12: Quiz — Advanced Prompting Techniques
Test your understanding of the advanced prompting techniques covered in this chapter. Each question has one best answer unless otherwise noted. Try to answer each question before revealing the hidden answer.
Question 1
What is the primary benefit of chain-of-thought prompting for coding tasks?
A) It makes the AI write longer responses B) It forces the AI to reason through the problem step-by-step before coding, improving correctness C) It reduces the number of tokens in the AI's response D) It makes the AI use more advanced language features
Answer
B) Chain-of-thought prompting asks the AI to explicitly reason through the problem — identifying inputs, outputs, edge cases, and algorithm design — before writing any code. This deliberate reasoning process catches errors that direct coding might miss, particularly for complex algorithmic problems.Question 2
When using few-shot prompting, how many examples are generally recommended for optimal results?
A) Exactly one B) Two to five C) At least ten D) As many as the context window allows
Answer
B) Research and practical experience suggest that two to five examples are usually sufficient. One example is often too few for the AI to distinguish pattern from coincidence. Beyond five, you spend context window space without proportional improvement in output quality.Question 3
Which scenario is the WORST candidate for chain-of-thought prompting?
A) Implementing a dynamic programming solution B) Writing a basic getter/setter method C) Designing a cache eviction strategy D) Building a graph traversal algorithm
Answer
B) Chain-of-thought prompting adds unnecessary verbosity to simple, well-defined tasks like getter/setter methods. It is best reserved for problems where explicit reasoning genuinely helps — algorithms, complex business logic, or architectural decisions. For straightforward tasks, a direct prompt is faster and just as effective.Question 4
A team provides the AI with eight nearly identical few-shot examples that only differ in variable names. What problem will this likely cause?
A) The AI will produce more creative solutions B) The AI may copy too rigidly and fail to generalize appropriately C) The AI will ignore all the examples D) The context window will be too small for a response
Answer
B) When examples are too similar, the AI may overfit to the specific pattern rather than learning the underlying intent. The AI might replicate surface-level details (like specific variable names or data types) rather than understanding the structural pattern it should generalize. Good few-shot examples should share structure but vary in content.Question 5
Which role-based prompt is more effective?
Prompt A: "Act as the world's best programmer and write a login system." Prompt B: "Act as a security engineer specializing in authentication. Implement a login system with bcrypt hashing, rate limiting, and audit logging."
A) Prompt A, because it sets higher expectations B) Prompt B, because it activates specific expertise and criteria C) They are equally effective D) Neither is effective; role-based prompting does not work
Answer
B) Role-based prompting derives its value from activating specific expertise and evaluation criteria, not from vague superlatives. Prompt B specifies a concrete role (security engineer in authentication) and includes actionable requirements. Prompt A's "best programmer" role provides no specific lens through which to evaluate or improve the output.Question 6
What is meta-prompting?
A) Writing prompts about prompts to improve prompt quality B) Writing very long prompts with extensive metadata C) Using multiple AI models simultaneously D) Encoding prompts in a special meta-language
Answer
A) Meta-prompting is the technique of using AI to improve your prompts. You describe your goal to the AI and ask it to generate an optimized prompt, which you then use (possibly with modifications) to get your actual result. It turns the AI into a prompt engineering assistant.Question 7
A developer's prompt chain has three steps, but they do NOT paste any output from Step 1 into Step 2. What will happen?
A) The AI will automatically remember the context from Step 1 B) Step 2 will produce output that may be inconsistent with Step 1's decisions C) The chain will work perfectly because AI has persistent memory D) The AI will refuse to answer Step 2
Answer
B) Without passing relevant output from one step to the next, the AI has no way to maintain consistency across the chain. Each prompt is processed independently, so Step 2 may make different design decisions than Step 1, leading to integration problems. Proper prompt chaining always includes relevant context from previous steps.Question 8
When should you use decomposition prompting?
A) For any task, regardless of complexity B) Only for tasks requiring more than 1,000 lines of code C) When the task has multiple components that benefit from focused individual attention D) Only when working with multiple AI assistants simultaneously
Answer
C) Decomposition prompting is valuable when a task has multiple logical components that each benefit from focused attention. The threshold is not about code line count specifically, but about whether the task has distinct concerns that would be better handled separately. Different parts might require different expertise, different testing strategies, or different levels of quality focus.Question 9
What is the primary risk of decomposition prompting?
A) Each module will be too simple B) The AI cannot handle individual modules C) Modules may work in isolation but fail to integrate coherently D) It uses too many API calls
Answer
C) The biggest risk is loss of coherence during integration. Each module might work perfectly on its own, but interfaces might not align, naming conventions might differ, or assumptions might conflict. This is prevented by defining interfaces before implementing any module and including interface contracts in every module's prompt.Question 10
In constraint satisfaction prompting, what is the difference between hard and soft constraints?
A) Hard constraints are technical; soft constraints are business-related B) Hard constraints must be met; soft constraints are preferred but negotiable C) Hard constraints are about performance; soft constraints are about style D) Hard constraints apply to production; soft constraints apply to development
Answer
B) Hard constraints are non-negotiable requirements that must be satisfied in the solution (e.g., "all passwords must be hashed"). Soft constraints are preferences that should be met if possible but can be skipped if they significantly complicate the design or conflict with hard constraints (e.g., "connection pooling for performance, if feasible"). This distinction helps the AI prioritize.Question 11
What is comparative prompting best suited for?
A) Generating the fastest possible code B) Making design decisions where multiple valid approaches exist with different trade-offs C) Writing code that combines multiple programming paradigms D) Comparing the AI's output with human-written code
Answer
B) Comparative prompting asks the AI to generate multiple solutions and explicitly compare their trade-offs. It is most valuable when there is no single "right" answer and the best approach depends on context — team expertise, performance requirements, maintenance burden, and other project-specific factors.Question 12
How many approaches should you typically request in a comparative prompt?
A) Exactly one B) Two or three C) Five to seven D) As many as possible for comprehensive analysis
Answer
B) Comparing two or three approaches produces thorough analysis with genuine depth. Asking for more than three approaches typically results in superficial treatment of each. The approaches should be genuinely different — not minor variations of the same idea — to provide meaningful comparison value.Question 13
What is Socratic prompting in the context of vibe coding?
A) Teaching the AI using the Socratic method B) Asking the AI to ask YOU questions to clarify requirements before coding C) Writing prompts in the form of philosophical questions D) Using questions instead of statements in every prompt
Answer
B) Socratic prompting inverts the typical interaction: instead of telling the AI what to build, you ask the AI to ask you questions that help clarify requirements, discover edge cases, and understand the problem more deeply before any code is written. The AI acts as a technical consultant interviewing you about your project.Question 14
A developer combines Socratic prompting with decomposition prompting. In what order should these techniques typically be applied?
A) Decomposition first, then Socratic B) Socratic first, then decomposition C) They should be applied simultaneously D) The order does not matter
Answer
B) Socratic prompting should come first to discover and clarify requirements. Only after requirements are clear should you decompose the system into modules. Decomposing before understanding requirements risks breaking the system into the wrong modules or missing important components entirely.Question 15
What is "context drift" in prompt chaining?
A) The AI gradually forgets earlier parts of the conversation B) Later prompts subtly contradict decisions made in earlier prompts C) The context window fills up and truncates earlier messages D) The AI changes its programming language mid-chain
Answer
B) Context drift occurs when later prompts in a chain produce output that subtly contradicts earlier decisions — for example, changing a method signature, renaming a class, or altering a return type. This happens because each prompt is processed with limited context about previous steps. It is prevented by including interface contracts in every step and explicitly noting "do not change any previously defined interfaces."Question 16
Which combination of techniques is recommended for building a complex system with unclear requirements?
A) Few-shot + constraint satisfaction B) Socratic + decomposition + chain-of-thought C) Meta-prompting + comparative D) Role-based + few-shot
Answer
B) When requirements are unclear, start with Socratic prompting to discover requirements through AI-guided questioning. Then use decomposition to break the clarified system into manageable modules. Finally, apply chain-of-thought to implement each module with careful reasoning. This combination addresses requirement ambiguity, system complexity, and implementation correctness in sequence.Question 17
What is the main advantage of maintaining a personal prompt library?
A) It impresses colleagues B) It enables consistent, efficient reuse of proven prompts that encode team knowledge C) It reduces the need to understand the techniques D) It eliminates the need for iterative refinement
Answer
B) A prompt library captures battle-tested prompts that consistently produce high-quality results. Key advantages include: consistency across team members, efficiency from not crafting prompts from scratch, preserved institutional knowledge that survives personnel changes, and systematic improvement over time through versioning.Question 18
A prompt library entry includes effectiveness_rating: 4.5 and a changelog with five versions. What does this suggest about the prompt?
A) The prompt was written by an expert B) The prompt has been iteratively refined based on real usage and produces reliable results C) The prompt is too complex D) The prompt needs to be replaced
Answer
B) A high effectiveness rating combined with multiple versions indicates a prompt that has been used in practice and improved over time based on real results. This is the hallmark of a well-maintained prompt library — prompts evolve through usage, and the versioning history provides transparency about how and why they changed.Question 19
What is "role stacking"?
A) Assigning the AI multiple simultaneous roles in a single prompt B) Changing roles across multiple conversations C) Using one role prompt inside another D) Having multiple AI assistants each with different roles
Answer
A) Role stacking uses multiple roles in a single prompt — for example, asking the AI to review code from the perspectives of a DBA, a security engineer, and a maintenance engineer simultaneously. This produces multi-dimensional analysis where each role contributes different insights, followed by a unified recommendation.Question 20
When using few-shot prompting for code transformation (e.g., converting sync to async), what is the most important quality of the examples?
A) They should be as long as possible B) They should demonstrate the structural transformation pattern clearly C) They should use the most advanced language features D) They should cover every possible edge case
Answer
B) For code transformation tasks, the examples should clearly demonstrate the structural mapping from input to output. The AI needs to understand the pattern of transformation — what changes, what stays the same, and how constructs map from one style to another. Clear, focused examples of the transformation pattern are more valuable than lengthy or edge-case-heavy examples.Question 21
A developer uses meta-prompting and receives an improved prompt from the AI. What should they do next?
A) Use the improved prompt exactly as generated B) Review and potentially customize the improved prompt before using it C) Run the meta-prompt again to get an even better version D) Discard it and write their own prompt
Answer
B) AI-generated prompts should be reviewed and customized. The AI may not know your specific project conventions, team preferences, or edge cases that matter to you. Use the generated prompt as a strong starting point, but add your domain knowledge and specific requirements before using it for code generation.Question 22
Which technique is most useful when you need generated code to match your team's existing coding style exactly?
A) Chain-of-thought prompting B) Few-shot prompting C) Socratic prompting D) Comparative prompting
Answer
B) Few-shot prompting excels at teaching the AI your specific patterns and conventions through concrete examples. By showing the AI two to three examples of code written in your team's style — with your naming conventions, error handling patterns, documentation format, and structural choices — the AI learns to produce code that matches.Question 23
In the decision framework presented in the chapter, what determines which technique(s) to use?
A) The size of the codebase B) The programming language being used C) The nature and characteristics of the specific task D) The specific AI model being used
Answer
C) The decision framework maps task characteristics to recommended techniques. Complex algorithms suggest chain-of-thought. Pattern matching suggests few-shot. Unclear requirements suggest Socratic. The choice is driven by what the task demands, not by the tools or languages involved.Question 24
What is the "constraint verification pattern"?
A) Writing constraints before writing the prompt B) Using a follow-up prompt to check whether generated code satisfies all stated constraints C) Automatically testing code against a constraint checklist D) Having the AI verify its own constraints before responding
Answer
B) The constraint verification pattern uses a follow-up prompt that asks the AI to review its own output against the original constraint list, marking each constraint as MET, PARTIAL, or NOT MET. This creates a natural verification loop that catches missed requirements before they become bugs in production.Question 25
A team stores their prompt library in their code repository alongside source code. What advantage does this provide? (Select the best answer)
A) It makes the prompts run faster B) Prompts benefit from the same version control, review process, and collaboration as code C) It reduces the repository size D) It allows the AI to read the prompts automatically
Answer
B) Storing prompts in the code repository subjects them to the same quality processes as source code: version control for tracking changes, pull requests for peer review, branch-based development for experimentation, and shared access for the entire team. This elevates prompt quality through the same collaborative processes that improve code quality.Scoring Guide
| Score | Level | Recommendation |
|---|---|---|
| 23–25 | Expert | You have mastered the advanced prompting techniques. Move on to Chapter 13. |
| 18–22 | Proficient | Strong understanding. Review the techniques you missed, then proceed. |
| 13–17 | Developing | Good foundation. Re-read the sections for questions you missed and retry. |
| 8–12 | Emerging | Review the chapter more carefully, focusing on the examples and callout boxes. |
| 0–7 | Beginning | Consider revisiting Chapter 8 (Fundamentals) before re-attempting this chapter. |