A recommendation or reference from a teacher, professor, or mentor can strongly support your applications for courses, scholarships, internships, and jobs, and asking for one well makes a real difference to how good it turns out. The key is to ask the right person, in the right way, with enough time and information, so they can write something genuine and strong rather than generic.
Choose someone who actually knows you and your work, not just the most senior or famous person available. A teacher who has seen your effort and can speak to specific strengths will write a far more convincing recommendation than a big name who barely remembers you. Once you have chosen, ask politely and in person or by a well written message, and ask early, giving them plenty of time rather than requesting it at the last minute, because a rushed recommendation is usually a weaker one, and last minute requests feel inconsiderate.
Make their job easy. When you ask, briefly remind them of who you are and what you worked on together, explain what the recommendation is for, and share useful details like your resume, the opportunity, any deadlines, and points you would appreciate them highlighting. This is not telling them what to write, it is giving them the material to write well. Always be gracious, accept a no politely if they decline, since some may not feel able to write a strong one, and thank them afterward regardless of the outcome. A thoughtful thank you also keeps the relationship warm for future needs. Asking respectfully and making it easy is what turns a favour into a genuinely strong recommendation.
Example: Emailing a professor two weeks ahead with a short reminder of your project together, the opportunity details, your resume, and the deadline gives them everything they need to write a strong, specific letter.
One practical tip: Ask early and make it easy. Give the person plenty of time plus your resume and the key details, so they can write something specific and strong rather than rushed and generic.