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.
☁️ New! Multi-Cloud Support (AWS & GCP)
Python Code Mentor now understands your cloud infrastructure code!
AWS Features
- Explain AWS Code: Select any boto3 or Lambda code and ask for an explanation.
- Trace Lambda: Get a step-by-step execution trace of your Lambda functions with simulated events.
- Analyze Architecture: Get insights into your AWS serverless patterns.
- Boto3 Helper: deep dive into boto3 API calls and parameters.
GCP Features
- Explain GCP Code: Understand Cloud Functions and Google Cloud SDK usage.
- Trace Cloud Function: Simulate execution flow for HTTP, Pub/Sub, and Storage triggers.
- Multi-Cloud Intelligence: Automatically detects hybrid architectures (e.g., using both S3 and Cloud Storage) and provides comparative insights.
How to use
Select your code and right-click, or use the Command Palette (Ctrl+Shift+P):
Python Mentor: Explain AWS/Lambda Code
Python Mentor: Trace Lambda Execution
Python Mentor: Explain GCP/Cloud Functions Code
Python Mentor: Trace Cloud Function Execution
🚀 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.
☕ Support the Project
If Python Code Mentor has helped you on your coding journey, consider supporting its development! Your contributions help keep this project free and updated with new features for everyone.

Every coffee counts and is deeply appreciated! 🚀
Happy Coding! 🐍