Lesson 1What a strong technical request includes
- State the exact language, framework and version. “Write a function in Python 3 using only the standard library, no external packages” beats “write a function in Python.”
- Describe inputs and expected outputs precisely, with an example if you can.
- Mention constraints that matter for your environment: performance limits, existing code style, libraries already used in the project.
- Ask it to explain, not just generate. “Explain what each part does” turns a black box into a learning opportunity.
Real-life example: Ama is building a web form for her course project. Weak: “Write code to validate a phone number.” Strong: “Write a Python function called validate_ghana_phone that takes a string and returns True if it matches a valid Ghanaian mobile number format (starting with 0, 10 digits total), False otherwise. Include 3 example test cases and a one-line comment explaining the regex pattern.” The second gives Ama code she can understand, test and defend.
def validate_ghana_phone(number: str) -> bool:
# 0 followed by exactly 9 more digits = 10 digits total
import re
return bool(re.fullmatch(r"0\d{9}", number.strip()))
print(validate_ghana_phone("0554646762")) # True
print(validate_ghana_phone("554646762")) # False
print(validate_ghana_phone("")) # False