Sub topic 2
Prompts That Ask for Hints and Explanations
Assume you know variables, functions, conditionals, loops, and how to run Python code. The goal is to use AI to strengthen your reasoning, not to replace it.
Ask for Understanding
Start with your own attempt. Then tell the AI what you tried, what you expected, and where you are stuck. Ask for one hint or one question at a time.
I am learning Python. I tried to write a function that returns the median of a list.
[paste your code and the error or wrong output]
Do not give me the full solution. Ask one question that helps me find the problem. If I am still stuck, give one hint. After I fix it, review my code.Useful requests include:
- “Explain this line in plain language.”
- “Show a smaller example with different values.”
- “What assumption in my reasoning might be wrong?”
- “Give me a test case, but not the solution.”
- “Review my code for clarity and edge cases.”
| Goal | Useful AI role | Example request |
|---|---|---|
| Understand an idea | Tutor | “Explain why this loop stops.” |
| Find a mistake | Reviewer | “Point out one suspicious line.” |
| Finish unfamiliar work | Generator | “Write a complete example.” |
Use the generator role carefully. It is useful for reference implementations, but copying its answer can hide gaps in your knowledge.
Where AI Answers Go Wrong
AI can produce code that looks reasonable but fails because it:
- Misreads an unclear requirement.
- Assumes inputs are always valid.
- Misses empty, unusually large, or duplicate values.
- Uses a library feature incorrectly.
- Gives an explanation that does not match the code.
Treat an AI answer as a claim to investigate. Separate the intended behavior from the implementation. Write down examples that should pass and examples that might expose an error.
Read Before You Accept
Read generated code in this order:
- State what the function should do.
- Trace the code with a small input by hand.
- Check each condition, loop, and return value.
- Look for assumptions about input types and limits.
- Run tests that you designed, including edge cases.
def count_vowels(text):
return sum(1 for ch in text.lower() if ch in "aeiou")
print(count_vowels("Learning with AI"))Before running it, predict the output. Then test an empty string, uppercase letters, and punctuation. If the result differs from your prediction, explain the difference before asking the AI.
Exercise
What should you ask an AI for before requesting a complete solution?
Show answer
Ask for a hint, a guiding question, or an explanation of the confusing part. Then test and explain the result yourself.