Python Code Mentor 🐍
AI-powered Python coding assistant that teaches understanding, not just copy-pasting.
This extension uses Google's Gemini AI to explain code logic, trace execution, identifying conceptual gaps, and more. It is designed specifically for beginners and learners.
Note: You must provide your own Google Gemini API key to use this extension.
🚀 Features
📘 Explain Code (Ctrl+Shift+E)
Select any Python code and get a beginner-friendly explanation of what it does, how it works, and why.
🔍 Trace Code Execution (Ctrl+Shift+T)
Visualize your code running step-by-step with sample input values. See exactly how variables change inside loops.
🆚 Compare Approaches (Ctrl+Shift+C)
Not sure if you should use a for loop or list comprehension? Type two versions and get a conceptual comparison of pros/cons (without being told "this one is better").
🧠 Analyze Logic (Ctrl+Shift+L)
Get feedback on your code's logic. Learn mental models to understand flow control and data structures better.
🧪 Interactive Quiz (Ctrl+Shift+Q)
Test your knowledge! Generate instant multiple-choice and fill-in-the-blank quizzes based on your own code.
📚 Snippet Library
Save your favorite explanations as "flashcards" in the sidebar to review later. Export them to JSON or Anki.
📊 Progress Tracking
Track your learning streaks and get weekly AI-generated insights about your learning patterns.
💎 Freemium & Pro
To cover development costs, the extension operates on a fair Freemium model:
- Free Tier: 20 AI requests per day.
- Pro Tier: One-time payment ($9.99) for Unlimited Access.
Upgrade to Pro to unlock unlimited learning.
⚙️ Setup
1. Get a Gemini API Key
- Go to Google AI Studio.
- Create a free API key.
- Install the extension.
- Press
Ctrl+, to open Settings.
- Search for
Python Code Mentor.
- Paste your API key into the Gemini Api Key field.
Security Note: Your API Key is stored locally in VS Code settings. It is never sent to our servers.
3. Change AI Model (Using Newer Models)
The extension relies on your Google AI Studio API key.
Recommended Models (free tier compatible):
gemini-2.5-flash (Default - Fast & Reliable)
gemini-2.5-latest
How to switch:
- Open Settings (
Ctrl+,).
- Search "Code Mentor Model".
- Enter the model ID (e.g.,
gemini-2.5-pro if you have a paid account).
Note: Gemini 1.5 is deprecated. Please use 2.5 series or newer.
❓ Troubleshooting
Error: [404 Not Found] models/gemini... is not found
- Cause: The default model version might not be available in your region or for your API key tier.
- Fix: Go to Settings and change Model Name to
gemini-pro (older but widely available) or checks Google's Model List.
Feedback? Questions? Feature requests?
- X (Twitter): @karaniph
- Issues: Please report bugs on the Marketplace page.
Happy Coding! 🐍