PromptSharp › Prompt Library › Learning › Coding exercise for beginners: write the tests first, then the code yourself
Coding exercise for beginners: write the tests first, then the code yourself
You are learning to code and the AI keeps writing the code for you. Get a small exercise with tests you understand, and a tutor that only gives hints.
The prompt — copy and run it
You are a programming tutor for beginners who believes the learner must write the code. I will tell you the language I am learning, what I have covered so far and how much time I have. Produce: A) THE EXERCISE — one small, self-contained problem that uses only concepts I have covered plus one new idea, stated plainly with two or three example inputs and the expected outputs. B) THE TESTS FIRST — help me write the tests before the code: list the cases to test (normal cases, an empty input, an edge case), and explain in words what each test checks. Do not write the test code unless I ask; I write it first and you check it. C) THE PLAN IN WORDS — ask me to describe, in plain sentences, how I would solve it before I write any code. Respond to my plan with questions, not corrections. D) THE HINT LADDER — when I am stuck, give hints in order of increasing help, one at a time: a question about my approach, the name of the concept I need, a pointer to the line where my code goes wrong, and only then a small example of the concept unrelated to my exercise. Never write my solution unless I say "I give up, show me". E) THE REVIEW — once my tests pass, review my code for readability and one improvement, and suggest a variation of the exercise for next time. Inputs: [LANGUAGE] · [WHAT I HAVE LEARNED SO FAR] · [TIME AVAILABLE] · [WHAT I FIND HARDEST] Rules: Do not write my solution code. Use only standard-library features unless I say otherwise, and do not invent library functions; if you mention one, tell me to verify it in the official documentation. Keep the exercise small enough to finish in my time. Do not invent facts, sources, citations, links, or specifics you cannot support — say "I'm not sure" instead, and mark anything I must verify for myself rather than asserting it. Never paste confidential, client, medical, or personally identifying information into a consumer AI tool, and don't ask me for any.
How to use this prompt
- Copy the full prompt above with the Copy button.
- Fill in your inputs. Replace each bracketed placeholder with your specifics:
[LANGUAGE][WHAT I HAVE LEARNED SO FAR][TIME AVAILABLE][WHAT I FIND HARDEST] - Paste into ChatGPT, Claude, or Gemini and run. Read the reality guardrail below before you act on the output.
Why this prompt works
Beginners who let an assistant write the code end up able to read programs but not write them. Writing tests and a plain-language plan before any code, then getting hints that increase in help one step at a time, keeps the problem-solving with the learner, and the review at the end adds feedback on quality without taking over the exercise.
Get a prompt like this in your inbox
The PromptSharp Learning Brief ships one desk-ready prompt every weekday — free on the web today. Free forever. Today's Learning issue is live on the web right now — subscribe and we email you the sample issue immediately, then the Learning daily by email most weekday mornings, plus a Sunday roundup. Unsubscribe anytime.
Subscribe free → Read a sample issueWant the full PromptSharp Learning Brief, not just the free prompt? Vertical Pro is the full Pro benefit set for ONE vertical. See what Pro includes.
Card required. Free for 14 days, then $14.99/month — renews automatically until you cancel. Cancel anytime before day 14 and you won’t be charged. One free trial per card. Manage or cancel anytime.
Frequently asked
When should I use this prompt?
You are learning to code and the AI keeps writing the code for you. Get a small exercise with tests you understand, and a tutor that only gives hints.
Why does this prompt work?
Beginners who let an assistant write the code end up able to read programs but not write them. Writing tests and a plain-language plan before any code, then getting hints that increase in help one step at a time, keeps the problem-solving with the learner, and the review at the end adds feedback on quality without taking over the exercise.
What mistake does this prompt help you avoid?
The assistant writing the solution, which prevents the learner building the skill. The hint ladder and a written plan keep the coding with the learner.
Related Learning prompts
One-page explainer for a real colleague: prove you understand it by writing it
You need to explain something you have learned to a colleague, a manager or a team. Write the one-page explainer yourself and have…
Flashcard writer: one fact per card, built only from your own notes
You know spaced repetition works but writing good cards takes forever, and bad cards waste reviews. Turn your notes into clean, si…
Worked-example fading: from studying a solution to producing one
You understand the worked examples but freeze on a blank problem. Use a sequence that removes one step of support at a time until …
Feedback loop for a skill with no grader: build your own rubric and checklist
You are practising writing, presenting, design or another skill with no exam and no teacher. Build a rubric so each practice piece…
Language plan built around the conversations you actually need to have
You are learning a language for a reason: a move, a partner's family, a work trip. Build the plan around those real conversations …
Error log review: find the patterns behind the questions you keep getting wrong
You have a pile of wrong answers from homework, quizzes and practice tests. Find the few patterns behind them so you fix causes, n…
Three-pass reading of a hard text — without outsourcing the thinking
A dense paper or chapter you need to actually understand, not skim. Use the model to scaffold your reading, not replace it.…
All Learning free prompts
The PromptSharp Learning Brief page — five full free prompts plus today's issue.
PromptSharp Daily — free
The cross-vertical sampler: one sharp, copy-paste prompt most weekday mornings, plus a Sunday roundup, rotating across the roster. Two things in one brief: you get better at AI and prompting, and you see the sharpest prompts from across the network. If a day's issue misses our quality bar, we hold it instead of padding your inbox.
Double-opt-in. Unsubscribe anytime. No spam, ever.
Even a sharp prompt starts from zero unless your AI knows you. Brainfile is persistent context — your work, voice, and priorities loaded into every session. Brainfile is the memory; PromptSharp is the playbook. Together they compound — the same prompt gets sharper because it runs on YOUR context.
Set up your brainfile →Want both? The All-Access + Brainfile annual bundle covers the pair.
Home · Daily Issues · Prompt Library · Glossary · Pricing · For Teams & Universities · Archive · PromptFluent alternative · Newsletter · Privacy · Terms · Refunds
Marketing · Sales · Dev & Engineering · Finance · Product Management · Vibe Coding · C-suite · Consulting & Strategy · Law · CPG · Personal Finance · Career & Job Search · Trading · Health & Fitness · Students · Focus & Productivity · Learning · Travel Planning
Entry Point Trading
Free weekly stocks to watch —
how our model ranks the S&P 500 and Nasdaq 100.