Gemini’s multimodal capabilities enable powerful educational applications—from personalized tutoring to automated grading and content generation. Process text, images, audio, and video to create engaging, adaptive learning experiences.
Solve complex problems with step-by-step explanations:
prompt = """Explain photosynthesis to a 10-year-old student.Use simple language, analogies, and break it into clear steps."""response = generate_content( model_id="gemini-2.0-flash", contents=prompt,)display(Markdown(response))
Output:
# How Plants Make Their Food! 🌱Photosynthesis is like a plant's kitchen! Here's how it works:1. **Ingredients**: Plants need three things: - Sunlight (energy) - Water (from the soil) - Carbon dioxide (from the air)2. **The Kitchen**: This happens in the leaves, in tiny parts called chloroplasts (they're green!)3. **Cooking**: The plant uses sunlight to mix water and carbon dioxide together4. **The Food**: This creates sugar (glucose) that the plant uses for energy5. **Bonus**: Plants also make oxygen, which we breathe!Think of it like baking a cake: You need ingredients, heat, and a recipe to makesomething delicious. Plants do the same thing—just with sunlight!
prompt = """A train travels 300 km in 4 hours. Another train travels 250 km in 3 hours.Which train is faster, and by how much?Provide:1. Step-by-step solution2. The answer3. How to check your work"""response = generate_content( model_id="gemini-2.0-flash", contents=prompt,)display(Markdown(response))
image_url = "gs://cloud-samples-data/generative-ai/image/geometry-diagram.png"prompt = """Look at this geometry diagram.Explain:1. What geometric shapes are shown?2. What properties do these shapes have?3. Create a practice problem using this diagram"""response = generate_content( model_id="gemini-2.5-flash", contents=[ prompt, Part.from_uri(file_uri=image_url, mime_type="image/png"), ],)display(Markdown(response))
def generate_practice_problems( topic: str, difficulty: str, num_problems: int,) -> str: """Generate customized practice problems.""" prompt = f"""Generate {num_problems} {difficulty} practice problems on {topic}.For each problem:1. State the problem clearly2. Provide hints3. Include the solution with explanationFormat as Markdown with sections. """ response = generate_content( model_id="gemini-2.0-flash", contents=prompt, temperature=0.7, # Some creativity for varied problems ) return response# Usageproblems = generate_practice_problems( topic="quadratic equations", difficulty="intermediate", num_problems=5,)display(Markdown(problems))
class EssayGrade(BaseModel): score: int # 0-100 thesis_clarity: int # 1-5 argument_strength: int # 1-5 organization: int # 1-5 grammar_mechanics: int # 1-5 strengths: list[str] areas_for_improvement: list[str] specific_feedback: str suggested_revisions: list[str]student_essay = """Climate change is one of the most pressing issues of our time...[Student's essay text]"""rubric = """Grading criteria:- Clear thesis statement (20%)- Strong supporting arguments with evidence (30%)- Logical organization and flow (20%)- Grammar, spelling, and mechanics (15%)- Proper citations and research (15%)"""response = client.models.generate_content( model="gemini-2.5-pro", contents=f"Grade this essay using the rubric.\n\nRubric:\n{rubric}\n\nEssay:\n{student_essay}", config=GenerateContentConfig( response_schema=EssayGrade, response_mime_type="application/json", ),)grade = response.parsedprint(f"Score: {grade.score}/100")print(f"\nStrengths:")for strength in grade.strengths: print(f" - {strength}")print(f"\nAreas for Improvement:")for area in grade.areas_for_improvement: print(f" - {area}")
# Student submits photo of handwritten math workhandwritten_work = "gs://samples/student-math-homework.jpg"prompt = """Analyze this handwritten math work.Check:1. Is the solution correct?2. Are the steps shown clearly?3. Are there any errors in calculation or logic?4. Provide specific feedback on where mistakes occurred5. Show the correct solution if needed"""response = generate_content( model_id="gemini-2.5-flash", contents=[ Part.from_uri(file_uri=handwritten_work, mime_type="image/jpeg"), prompt, ],)display(Markdown(response))
diagram_url = "gs://samples/complex-diagram.png"prompt = """Generate comprehensive alt text for this educational image.Include:1. Brief description (for screen readers)2. Detailed description (for study notes)3. Key information that sighted students would extract"""response = generate_content( model_id="gemini-2.5-flash", contents=[ Part.from_uri(file_uri=diagram_url, mime_type="image/png"), prompt, ],)print(response)
complex_text = """The mitochondrion is a double-membrane-bound organelle found in most eukaryotic organisms. Mitochondria generate most of the cell's supply of adenosine triphosphate, used as a source of chemical energy."""prompt = f"""Simplify this text for students with different reading levels.Provide 3 versions:1. Elementary (grades 3-5)2. Middle school (grades 6-8) 3. High school (grades 9-12)Text: {complex_text}"""response = generate_content( model_id="gemini-2.0-flash", contents=prompt,)display(Markdown(response))