In Part 1, you will prepare Gemini API access and complete a set of quizzes. You will reuse the Gemini key later while coding.
You will:
- create a free API key in Google AI Studio
- complete a set of quizzes
Before starting:
- In Visual Studio Code terminal, update your local repository (do this each time before you start, since new updates may be available).
Full repository update, recommended:
git pull origin mainDo not run this. Keep it as an option to refresh only session material when needed.
git fetch origin
git restore --source origin/main --staged --worktree session2
git clean -fdn session2
# Review the preview first, then run:
git clean -fd -e session2/solutions session2Warning
git clean deletes untracked files. Keep your own work inside session2/solutions and use the command above with -e session2/solutions to protect it.
- Open the
session2folder in Visual Studio Code and in terminal.
cd session2
- Create
python3 -m venv .venvand activate your virtual environment:
source .venv/bin/activateWindows PowerShell:
.venv\Scripts\Activate.ps1- Install requirements:
pip install -r requirements.txtGo to Google AI Studio, login using your personal gmail account and create an API key:
- https://aistudio.google.com/app/api-keys
- Add a name (or keep the default) and choose
Default Gemini Project. - Create a key and keep it private.
- Copy the API key (for example,
AIza...).
Return to your Visual Studio Code terminal. On macOS/Linux, run the following command (replace with your API key):
export GEMINI_API_KEY="PASTE_YOUR_KEY"On Windows PowerShell:
$env:GEMINI_API_KEY="PASTE_YOUR_KEY"Tip
You can either use an OPENAI_API_KEY if you have one. Gemini is free to use, but there are some limits.
Test key is set
Run this quick check in your terminal:
python3 -c 'import os; k=os.getenv("GEMINI_API_KEY"); print("GEMINI_API_KEY set:", bool(k)); print("Key length:", len(k) if k else 0)'If GEMINI_API_KEY set: True appears and key length is greater than 0, your environment variable is working. Clear your terminal using clear, and let's proceed.
Limits note
Google AI Studio is free, but it has usage limits (typically 5-15 requests per minute, depending on the model).
Tip
Limits depend on model and tier, and can change over time.
Check the latest limits before running: https://ai.google.dev/gemini-api/docs/quota. If you exceed limits, you may receive 429 errors until quota resets.
Essay quizzes
Essay quizzes are a way for you to share your thoughts and have AI evaluate your answer against Stelios's approach to solving the problem. Read the instructions carefully before you start.
- Type your answer in the prompt.
- Press
Enterfor a new line. - Type
/endon its own line to finish. - AI will then evaluate your answer.
Make your terminal window larger for better visibility.
Essay quiz 1:
quizmd quizzes/python-data-cleaning-tradeoff-essay.mdEssay quiz 2:
quizmd quizzes/python-complexity-basics-essay.mdDebug quizzes
A debug quiz helps you find and fix errors in code. Read each prompt carefully before you start editing. Change only what is needed, line by line. Use hints if you get stuck.
Rules:
- Press
Dordto unlock the editor and fix the code - Line numbers are shown by default
- Press
Escto open actions - In actions, choose Proceed or Show hint with
↑/↓, then pressEnter - The hint points to the line where the error exists
- Press
Ctrl+Cto exit at any time - Follow code style. Use spaces around operators, for example:
x = 0(notx= 0).
Try it out:
quizmd quizzes/python-session-01-debug-quiz.md