<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Raspberry Pi &#8211; sekol.ninja</title>
	<atom:link href="https://sekol.ninja/category/raspberry-pi/feed/" rel="self" type="application/rss+xml" />
	<link>https://sekol.ninja</link>
	<description></description>
	<lastBuildDate>Wed, 10 Jun 2026 13:43:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Build Your Own AI-Powered Choose Your Own Adventure</title>
		<link>https://sekol.ninja/build-your-own-ai-powered-choose-your-own-adventure/</link>
		
		<dc:creator><![CDATA[Michael Sekol]]></dc:creator>
		<pubDate>Wed, 10 Jun 2026 12:02:53 +0000</pubDate>
				<category><![CDATA[Learning to Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[Choose your own adventure]]></category>
		<category><![CDATA[Learn to Code]]></category>
		<category><![CDATA[Summer Camp]]></category>
		<guid isPermaLink="false">https://sekol.ninja/?p=10640</guid>

					<description><![CDATA[A Step-by-Step Python Guide for Beginners In this project, you will write a Python program that uses real artificial intelligence (ChatGPT) to [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">A Step-by-Step Python Guide for Beginners</h3>



<p class="wp-block-paragraph">In this project, you will write a Python program that uses real artificial intelligence</p>



<p class="wp-block-paragraph">(ChatGPT) to create a story that changes based on YOUR choices.</p>



<p class="wp-block-paragraph">Every time you play, the story will be different!</p>



<p class="wp-block-paragraph"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-global-color-2-color">No coding experience needed — just follow the steps!</mark></p>



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
  /* Reset for WordPress compatibility */
  .adventure-guide * { box-sizing: border-box !important; }
  .adventure-guide {
    font-family: 'Segoe UI', Arial, sans-serif !important;
    max-width: 860px !important;
    margin: 0 auto !important;
    padding: 20px !important;
    color: #333 !important;
    line-height: 1.7 !important;
    font-size: 16px !important;
  }
  .adventure-guide h1 {
    color: #1B365D !important;
    font-size: 2em !important;
    border-bottom: 3px solid #2E75B6 !important;
    padding-bottom: 10px !important;
    margin-top: 40px !important;
    margin-bottom: 20px !important;
  }
  .adventure-guide h2 {
    color: #2E75B6 !important;
    font-size: 1.5em !important;
    margin-top: 35px !important;
    margin-bottom: 15px !important;
  }
  .adventure-guide h3 {
    color: #333 !important;
    font-size: 1.2em !important;
    margin-top: 25px !important;
    margin-bottom: 10px !important;
  }
  .adventure-guide p {
    margin: 10px 0 !important;
    line-height: 1.7 !important;
  }
  .adventure-guide .hero-section {
    text-align: center !important;
    padding: 40px 20px !important;
    margin-bottom: 30px !important;
    background: linear-gradient(135deg, #1B365D, #2E75B6) !important;
    color: white !important;
    border-radius: 12px !important;
  }
  .adventure-guide .hero-section h1 {
    color: white !important;
    border-bottom: none !important;
    font-size: 2.2em !important;
    margin: 0 0 10px 0 !important;
  }
  .adventure-guide .hero-section p {
    color: rgba(255,255,255,0.9) !important;
    font-size: 1.1em !important;
    margin: 5px 0 !important;
  }
  /* Callout boxes */
  .adventure-guide .box {
    border-radius: 8px !important;
    padding: 18px 22px !important;
    margin: 16px 0 !important;
    border-left: 5px solid #ccc !important;
  }
  .adventure-guide .box-title {
    font-weight: bold !important;
    margin-bottom: 8px !important;
    color: #1B365D !important;
    font-size: 1.05em !important;
  }
  .adventure-guide .box-purple {
    background-color: #F3E5F5 !important;
    border-left-color: #9C27B0 !important;
  }
  .adventure-guide .box-green {
    background-color: #E8F5E9 !important;
    border-left-color: #4CAF50 !important;
  }
  .adventure-guide .box-orange {
    background-color: #FFF3E0 !important;
    border-left-color: #FF9800 !important;
  }
  .adventure-guide .box-red {
    background-color: #FFEBEE !important;
    border-left-color: #F44336 !important;
  }
  .adventure-guide .box-teal {
    background-color: #E0F7FA !important;
    border-left-color: #00BCD4 !important;
  }
  .adventure-guide .box-blue {
    background-color: #E8F0FE !important;
    border-left-color: #2E75B6 !important;
  }
  /* Code blocks */
  .adventure-guide pre {
    background-color: #1E1E1E !important;
    color: #D4D4D4 !important;
    border-radius: 8px !important;
    padding: 18px 22px !important;
    margin: 16px 0 !important;
    overflow-x: auto !important;
    font-family: 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    border: 1px solid #333 !important;
  }
  .adventure-guide pre .comment { color: #6A9955 !important; }
  .adventure-guide pre .string { color: #CE9178 !important; }
  .adventure-guide pre .keyword { color: #569CD6 !important; }
  .adventure-guide pre .function { color: #DCDCAA !important; }
  .adventure-guide pre .number { color: #B5CEA8 !important; }
  /* Inline code */
  .adventure-guide code {
    background-color: #f0f0f0 !important;
    color: #333 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-family: 'Courier New', monospace !important;
    font-size: 0.9em !important;
  }
  .adventure-guide pre code {
    background: none !important;
    color: inherit !important;
    padding: 0 !important;
    border-radius: 0 !important;
    font-size: inherit !important;
  }
  /* Terminal commands */
  .adventure-guide .terminal-cmd {
    background-color: #E8F5E9 !important;
    border-left: 5px solid #4CAF50 !important;
    padding: 12px 18px !important;
    border-radius: 8px !important;
    margin: 12px 0 !important;
    font-family: 'Courier New', monospace !important;
    font-size: 15px !important;
    color: #333 !important;
  }
  /* Step headers */
  .adventure-guide .step-header {
    display: flex !important;
    align-items: baseline !important;
    gap: 10px !important;
    margin-top: 35px !important;
    margin-bottom: 15px !important;
    padding-bottom: 8px !important;
    border-bottom: 2px solid #E8F0FE !important;
  }
  .adventure-guide .step-num {
    color: #2E75B6 !important;
    font-size: 1.6em !important;
    font-weight: bold !important;
    white-space: nowrap !important;
  }
  .adventure-guide .step-title {
    color: #1B365D !important;
    font-size: 1.6em !important;
    font-weight: bold !important;
  }
  /* Color key grid */
  .adventure-guide .color-key {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin: 20px 0 !important;
  }
  @media (max-width: 600px) {
    .adventure-guide .color-key { grid-template-columns: 1fr !important; }
    .adventure-guide .step-header { flex-direction: column !important; gap: 2px !important; }
  }
  .adventure-guide .color-key .box { margin: 0 !important; }
  /* Table */
  .adventure-guide table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 16px 0 !important;
    font-size: 0.95em !important;
  }
  .adventure-guide th {
    background-color: #1B365D !important;
    color: white !important;
    padding: 10px 14px !important;
    text-align: left !important;
    font-weight: bold !important;
  }
  .adventure-guide td {
    padding: 10px 14px !important;
    border: 1px solid #ddd !important;
    vertical-align: top !important;
  }
  .adventure-guide tr:nth-child(even) td { background-color: #f5f8ff !important; }
  .adventure-guide ul { margin: 8px 0 !important; padding-left: 24px !important; }
  .adventure-guide li { margin: 4px 0 !important; }
  .adventure-guide a { color: #2E75B6 !important; }
</style>
</head>
<body>
<div class="adventure-guide">

<!-- HERO -->
<div class="hero-section">
  <h1>In this project, you will write a Python program that uses real artificial intelligence (ChatGPT) to create a story that changes based on <strong>your</strong> choices. Every time you play, the story will be different!</h1>
  <p style="margin-top: 15px !important; font-style: italic !important; opacity: 0.85 !important;"></p>
</div>

<!-- COLOR KEY -->
<h1>How to Read This Guide</h1>
<p>This guide uses color-coded boxes to help you know what you&#8217;re looking at:</p>

<div class="color-key">
  <div class="box box-purple"><div class="box-title">🟣 PURPLE — New Vocabulary</div>Explains new words or concepts.</div>
  <div class="box box-green"><div class="box-title">🟢 GREEN — Terminal Commands</div>Commands for the terminal, NOT Thonny.</div>
  <div class="box box-orange"><div class="box-title">🟠 ORANGE — Tips &#038; Hints</div>Helpful tips and suggestions.</div>
  <div class="box box-red"><div class="box-title">🔴 RED — Warnings &#038; Mistakes</div>Common errors and how to fix them.</div>
</div>
<div class="color-key" style="margin-top: 0 !important;">
  <div class="box box-teal"><div class="box-title">🟦 TEAL — Expected Output</div>What you should see on screen.</div>
  <div class="box" style="background: #1E1E1E !important; border-left-color: #555 !important; color: #D4D4D4 !important;"><div class="box-title" style="color: #D4D4D4 !important;">⬛ DARK — Code to Type</div>Type this exactly into Thonny.</div>
</div>

<!-- WHAT YOU NEED -->
<h1>What You Need Before Starting</h1>
<ul>
  <li><strong>A Raspberry Pi</strong> that is turned on, connected to a monitor, keyboard, mouse, and the internet (Wi-Fi).</li>
  <li><strong>Thonny</strong> — the program where you write your code. It&#8217;s already installed on every Raspberry Pi. Look for a blue and white icon on the desktop or in the menu under <strong>Programming</strong>.</li>
  <li><strong>An API key</strong> — a special password that lets your program talk to ChatGPT. You&#8217;ll copy and paste it from <a href="https://www.sekol.ninja" target="_blank">www.sekol.ninja</a>.</li>
</ul>

<div class="box box-purple">
  <div class="box-title">🟣 New Vocabulary: What is an API Key?</div>
  <p>An <strong>API key</strong> is like a special password that lets one computer program talk to another. In this project, your Python program needs to talk to ChatGPT (which lives on the internet). The API key proves to ChatGPT that you have permission to use it.</p>
  <p>Think of it like a library card — the library (ChatGPT) won&#8217;t let you borrow books (get AI responses) unless you show your card (API key).</p>
</div>

<!-- STEP 1 -->
<div class="step-header"><span class="step-num">Step 1:</span><span class="step-title">Open the Terminal</span></div>

<p>First, we need to install a small piece of software that lets Python talk to ChatGPT. To do this, we&#8217;ll use the <strong>terminal</strong> — the black window where you type commands directly to the computer.</p>
<p>Click the <strong>black rectangle icon</strong> in the top taskbar of your Raspberry Pi. A black window with a blinking cursor should open.</p>

<div class="box box-purple">
  <div class="box-title">🟣 New Vocabulary: What is the Terminal?</div>
  <p>The <strong>terminal</strong> (also called the &#8220;command line&#8221;) is a way to talk to your computer by typing text commands instead of clicking buttons. It&#8217;s what hackers use in movies! But in real life, it&#8217;s just a tool that programmers and cybersecurity experts use every day.</p>
</div>

<!-- STEP 2 -->
<div class="step-header"><span class="step-num">Step 2:</span><span class="step-title">Install the OpenAI Library</span></div>

<p>Type the following command into the terminal and press <strong>Enter</strong>:</p>
<div class="terminal-cmd">pip install openai</div>
<p>Wait for it to finish. You&#8217;ll see some text scroll by as it downloads and installs. When you see the blinking cursor again, it&#8217;s done.</p>

<div class="box box-purple">
  <div class="box-title">🟣 New Vocabulary: What is a Library?</div>
  <p>A <strong>library</strong> (in coding) is a bundle of pre-written code that someone else made for you. Instead of writing hundreds of lines of code to connect to ChatGPT yourself, you just install the <code>openai</code> library and it handles all the complicated stuff. Think of it like using a recipe from a cookbook instead of inventing a dish from scratch.</p>
</div>

<div class="box box-red">
  <div class="box-title">🔴 If You See an Error</div>
  <p>If you see a red error message, try this command instead:</p>
  <div class="terminal-cmd" style="background-color: #ffcdd2 !important; border-left-color: #c62828 !important;">pip install openai &#8211;break-system-packages</div>
  <p>This is a Raspberry Pi-specific thing. It&#8217;s safe and normal.</p>
</div>

<!-- STEP 3 -->
<div class="step-header"><span class="step-num">Step 3:</span><span class="step-title">Open Thonny and Create a New File</span></div>

<p>Now close the terminal (type <code>exit</code> or click the X). Open <strong>Thonny</strong> by clicking its icon (blue and white logo) on the desktop, or find it in the Raspberry Pi menu under <strong>Programming → Thonny</strong>.</p>
<p>When Thonny opens, you&#8217;ll see two sections:</p>
<ul>
  <li><strong>Top section</strong> — this is where you write your code (the &#8220;editor&#8221;)</li>
  <li><strong>Bottom section</strong> — this is where your program&#8217;s output appears (the &#8220;shell&#8221;)</li>
</ul>
<p>Click <strong>File → Save As</strong>. Name your file <code>adventure.py</code> and save it to the Desktop.</p>

<div class="box box-red">
  <div class="box-title">🔴 Important: The File Name Must End in .py</div>
  <p>Python files always end in <code>.py</code> — this tells the computer it&#8217;s a Python program. Make sure you type <code>adventure.py</code> (not just <code>adventure</code>).</p>
</div>

<!-- STEP 4 -->
<div class="step-header"><span class="step-num">Step 4:</span><span class="step-title">Import the Library</span></div>

<p>Now we start writing code! In the <strong>top section</strong> of Thonny (the editor), type the following:</p>

<pre><code><span class="comment"># ============================================</span>
<span class="comment"># CHOOSE YOUR OWN ADVENTURE</span>
<span class="comment"># Powered by AI (ChatGPT)</span>
<span class="comment"># ============================================</span>

<span class="comment"># Import the library we need</span>
<span class="keyword">from</span> openai <span class="keyword">import</span> OpenAI</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p>Lines that start with <code>#</code> are called <strong>comments</strong>. The computer completely ignores them. They&#8217;re notes for humans reading the code.</p>
  <p>The line <code>from openai import OpenAI</code> tells Python: &#8220;Go find the openai library we installed, and bring in the tool called OpenAI so we can use it.&#8221;</p>
</div>

<!-- STEP 5 -->
<div class="step-header"><span class="step-num">Step 5:</span><span class="step-title">Connect to ChatGPT</span></div>

<p>Press <strong>Enter</strong> twice after the last line (to leave a blank line), then type:</p>

<pre><code><span class="comment"># Set up the connection to ChatGPT</span>
<span class="comment"># Get your API key from www.sekol.ninja</span>
client = OpenAI(api_key=<span class="string">"paste-your-api-key-here"</span>)</code></pre>

<div class="box box-orange">
  <div class="box-title">❗ Getting Your API Key</div>
  <p>You need to replace <code>paste-your-api-key-here</code> with a real API key.</p>
  <p><strong>Go to <a href="https://www.sekol.ninja" target="_blank">www.sekol.ninja</a> in your web browser and copy the API key from the page.</strong></p>
  <p>Then come back to Thonny and paste it between the quotation marks. It will look something like:<br>
  <code>client = OpenAI(api_key="sk-abc123xyz456...")</code></p>
  <p><strong>Keep the quotation marks!</strong> The key must be inside the quotes.</p>
</div>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p>This line creates a <strong>client</strong> — think of it as a phone that can call ChatGPT. The API key is like the phone number. Without it, you can&#8217;t make the call.</p>
</div>

<!-- STEP 6 -->
<div class="step-header"><span class="step-num">Step 6:</span><span class="step-title">Give the AI Its Personality</span></div>

<p>This is the fun part! We&#8217;re going to tell ChatGPT what kind of storyteller it should be. Add this code below what you already have:</p>

<pre><code><span class="comment"># Tell the AI what kind of stories to create</span>
system_message = {
    <span class="string">"role"</span>: <span class="string">"system"</span>,
    <span class="string">"content"</span>: <span class="string">"""You are an adventure story master for kids.
You create exciting choose-your-own-adventure stories.

RULES:
- Keep the story fun, exciting, and kid-friendly.
- Each response should be 2-3 short paragraphs.
- Always end with exactly 3 numbered choices for what to do next.
- Use vivid descriptions to make the story come alive.
- The story should have a sci-fi space adventure theme.
- Never include anything scary, violent, or inappropriate."""</span>
}</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p>This creates a <strong>system message</strong> — it&#8217;s like a set of instructions you whisper to ChatGPT before the conversation starts. The player never sees this, but it controls HOW the AI tells the story.</p>
  <p><code>"role": "system"</code> tells ChatGPT &#8220;these are your instructions, not something the user said.&#8221;</p>
  <p>The three quotation marks <code>"""</code> let you write a message that spans multiple lines.</p>
</div>

<div class="box box-orange">
  <div class="box-title">🟠 Customize the Theme!</div>
  <p>Want a fantasy adventure instead of sci-fi? A mystery? A pirate story? Change the RULES section to whatever you want! This is YOUR story engine.</p>
</div>

<!-- STEP 7 -->
<div class="step-header"><span class="step-num">Step 7:</span><span class="step-title">Create the Conversation History</span></div>

<p>Add this line below the system message:</p>

<pre><code><span class="comment"># Create a list to keep track of the conversation</span>
conversation = [system_message]</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p>ChatGPT doesn&#8217;t have a memory on its own. Every time you send it a message, you have to send the <strong>entire conversation so far</strong>. This list called <code>conversation</code> stores every message — both yours and the AI&#8217;s.</p>
  <p>Right now it only contains the system message. As the game goes on, we&#8217;ll add more messages to this list.</p>
</div>

<!-- STEP 8 -->
<div class="step-header"><span class="step-num">Step 8:</span><span class="step-title">Create the Welcome Screen</span></div>

<p>Add a welcome screen that the player sees when they start:</p>

<pre><code><span class="comment"># Print the welcome screen</span>
<span class="function">print</span>(<span class="string">"="</span> * <span class="number">50</span>)
<span class="function">print</span>(<span class="string">"  CHOOSE YOUR OWN ADVENTURE"</span>)
<span class="function">print</span>(<span class="string">"  Powered by AI"</span>)
<span class="function">print</span>(<span class="string">"="</span> * <span class="number">50</span>)
<span class="function">print</span>()</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p><code>print()</code> displays text on the screen. <code>"=" * 50</code> means &#8220;repeat the = sign 50 times&#8221; — it makes a nice decorative line. <code>print()</code> with nothing inside prints a blank line for spacing.</p>
</div>

<!-- STEP 9 -->
<div class="step-header"><span class="step-num">Step 9:</span><span class="step-title">Ask for the Player&#8217;s Name</span></div>

<pre><code><span class="comment"># Ask the player for their name</span>
player_name = <span class="function">input</span>(<span class="string">"Enter your character's name: "</span>)
<span class="function">print</span>()
<span class="function">print</span>(<span class="string">"Welcome, "</span> + player_name + <span class="string">"! Your adventure begins..."</span>)
<span class="function">print</span>()</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p><code>input()</code> pauses the program and waits for the player to type something. Whatever they type gets stored in <code>player_name</code>.</p>
  <p>The <code>+</code> sign connects pieces of text together. So if the player types &#8220;Luna&#8221;, it prints: <em>Welcome, Luna! Your adventure begins&#8230;</em></p>
</div>

<!-- STEP 10 -->
<div class="step-header"><span class="step-num">Step 10:</span><span class="step-title">Send the First Message</span></div>

<pre><code><span class="comment"># Create the first message to start the story</span>
first_message = {
    <span class="string">"role"</span>: <span class="string">"user"</span>,
    <span class="string">"content"</span>: <span class="string">"Start a new adventure story. My character's name is "</span> + player_name + <span class="string">". Begin the story!"</span>
}
conversation.append(first_message)</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do?</div>
  <p>This creates a message with <code>"role": "user"</code> — meaning it&#8217;s FROM the player TO the AI.</p>
  <p><code>.append()</code> means &#8220;add to the end of the list.&#8221; Now our <code>conversation</code> list has two items: the system message AND this first user message.</p>
</div>

<!-- STEP 11 -->
<div class="step-header"><span class="step-num">Step 11:</span><span class="step-title">Build the Game Loop</span></div>

<p>This is the biggest section — the engine that makes the whole game run. It&#8217;s a <strong>loop</strong> that keeps going: send a message to ChatGPT → show the story → ask the player → repeat.</p>

<p><strong>⚠️ Indentation (the spaces at the beginning of lines) is very important in Python.</strong> Everything inside the loop must be indented with 4 spaces. Thonny should add the spaces automatically when you press Enter after a line ending with <code>:</code></p>

<pre><code><span class="comment"># The game loop</span>
<span class="keyword">while</span> True:
    <span class="comment"># Send the conversation to ChatGPT</span>
    response = client.chat.completions.create(
        model=<span class="string">"gpt-4o-mini"</span>,
        messages=conversation
    )

    <span class="comment"># Get the AI's story text</span>
    story_text = response.choices[<span class="number">0</span>].message.content

    <span class="comment"># Save the response to conversation history</span>
    conversation.append({
        <span class="string">"role"</span>: <span class="string">"assistant"</span>,
        <span class="string">"content"</span>: story_text
    })

    <span class="comment"># Display the story</span>
    <span class="function">print</span>(story_text)
    <span class="function">print</span>()

    <span class="comment"># Ask what the player wants to do</span>
    choice = <span class="function">input</span>(<span class="string">"What do you choose? (1, 2, 3, or 'quit'): "</span>)

    <span class="comment"># If they type quit, end the game</span>
    <span class="keyword">if</span> choice.lower() == <span class="string">"quit"</span>:
        <span class="function">print</span>()
        <span class="function">print</span>(<span class="string">"Thanks for playing, "</span> + player_name + <span class="string">"!"</span>)
        <span class="function">print</span>(<span class="string">"May the Code be with you!"</span>)
        <span class="keyword">break</span>

    <span class="comment"># Send the player's choice to the AI</span>
    conversation.append({
        <span class="string">"role"</span>: <span class="string">"user"</span>,
        <span class="string">"content"</span>: <span class="string">"I choose option "</span> + choice
    })

    <span class="function">print</span>()
    <span class="function">print</span>(<span class="string">"Generating next chapter..."</span>)
    <span class="function">print</span>()</code></pre>

<div class="box box-purple">
  <div class="box-title">🟣 What Does This Code Do? (Section by Section)</div>
  <p><strong>while True:</strong> — Creates a loop that runs forever (until we stop it). Each cycle = one &#8220;turn&#8221; of the adventure.</p>
  <p><strong>client.chat.completions.create(&#8230;)</strong> — This is the line that actually calls ChatGPT! It sends the entire conversation and gets back a response.</p>
  <p><strong>response.choices[0].message.content</strong> — The AI&#8217;s response comes in a structured package. This pulls out just the story text.</p>
  <p><strong>conversation.append(&#8230;)</strong> — Saves the AI&#8217;s response to our conversation list so it remembers what happened.</p>
  <p><strong>input(&#8230;)</strong> — Pauses and waits for the player to type their choice.</p>
  <p><strong>if choice.lower() == &#8220;quit&#8221;:</strong> — Checks if the player typed &#8220;quit&#8221; (or &#8220;QUIT&#8221; or &#8220;Quit&#8221; — <code>.lower()</code> converts it to lowercase first).</p>
  <p><strong>break</strong> — Stops the loop and ends the game.</p>
</div>

<div class="box box-red">
  <div class="box-title">🔴 Watch the Indentation!</div>
  <p>Every line inside the <code>while True:</code> loop must start with <strong>4 spaces</strong>. Every line inside the <code>if</code> block must start with <strong>8 spaces</strong> (4 for the loop + 4 for the if).</p>
  <p>If you see <code>IndentationError</code>, check that every line has the right number of spaces. Thonny usually handles this automatically, but if you&#8217;ve been copying and pasting, the spacing might be off.</p>
</div>

<!-- STEP 12 -->
<div class="step-header"><span class="step-num">Step 12:</span><span class="step-title">Save and Run Your Program!</span></div>

<p>You&#8217;re done writing code! Time to test it.</p>
<ol>
  <li>Press <strong>Ctrl + S</strong> to save your file.</li>
  <li>Press the green <strong>Run ▶</strong> button at the top of Thonny (or press <strong>F5</strong>).</li>
  <li>Look at the bottom section of Thonny (the shell). You should see:</li>
</ol>

<div class="box box-teal">
<pre style="background: #E0F7FA !important; color: #333 !important; border: none !important; margin: 0 !important; padding: 0 !important;"><code style="color: #333 !important;">==================================================
  CHOOSE YOUR OWN ADVENTURE
  Powered by AI
==================================================

Enter your character's name: </code></pre>
</div>

<ol start="4">
  <li>Type a character name and press Enter. Wait a few seconds while ChatGPT generates the first chapter.</li>
  <li>Read the story! At the end, you&#8217;ll see 3 choices. Type <code>1</code>, <code>2</code>, or <code>3</code> and press Enter.</li>
  <li>When you&#8217;re done playing, type <code>quit</code> to end.</li>
</ol>

<div class="box box-orange">
  <div class="box-title">🟠 It Takes a Few Seconds!</div>
  <p>After you make a choice, the program sends your message to ChatGPT over the internet and waits for a response. This usually takes 3–10 seconds. Just be patient — the AI is writing your story!</p>
</div>

<!-- TROUBLESHOOTING -->
<h1>Troubleshooting</h1>
<p>If something goes wrong, check here first:</p>

<table>
  <thead><tr><th>Error</th><th>What to Do</th></tr></thead>
  <tbody>
    <tr><td><code>ModuleNotFoundError: No module named 'openai'</code></td><td>You skipped Step 2. Open the terminal and run: <code>pip install openai --break-system-packages</code></td></tr>
    <tr><td><code>AuthenticationError</code> or <code>Invalid API key</code></td><td>Your API key is wrong. Go back to <a href="https://www.sekol.ninja" target="_blank">www.sekol.ninja</a>, copy the key again, and make sure it&#8217;s pasted between the quotation marks. No extra spaces.</td></tr>
    <tr><td><code>IndentationError</code></td><td>Your spacing is wrong. Lines inside the while loop need 4 spaces. Lines inside the if block need 8 spaces. Delete the spaces and re-type them.</td></tr>
    <tr><td><code>SyntaxError</code></td><td>You have a typo. Check for missing quotation marks, missing colons (<code>:</code>) after <code>while True</code> and <code>if</code> statements, and missing parentheses.</td></tr>
    <tr><td>Program runs but nothing happens</td><td>It&#8217;s waiting for you to type! Look at the bottom of Thonny (the shell) for a blinking cursor.</td></tr>
    <tr><td><code>ConnectionError</code> or <code>Timeout</code></td><td>Your Pi isn&#8217;t connected to the internet. Check Wi-Fi (click the icon in the top-right).</td></tr>
    <tr><td><code>RateLimitError</code></td><td>Too many people using the key at once. Wait 30 seconds and try again.</td></tr>
  </tbody>
</table>

<!-- CUSTOMIZE -->
<h1>Make It Your Own!</h1>

<div class="box box-orange">
  <div class="box-title">🎨 Change the Story Theme</div>
  <p>Edit the system_message content (Step 6) to change what kind of stories the AI tells. Try:</p>
  <ul>
    <li>A fantasy quest with dragons and wizards</li>
    <li>A mystery detective story</li>
    <li>A pirate adventure on the high seas</li>
    <li>A zombie survival story (kid-friendly of course!)</li>
    <li>A time-travel adventure through history</li>
  </ul>
</div>

<div class="box box-orange">
  <div class="box-title">🚀 Add More Player Customization</div>
  <p>Ask the player more questions at the start:</p>
  <pre style="margin: 8px 0 !important;"><code>companion = <span class="function">input</span>(<span class="string">"Name your sidekick: "</span>)
superpower = <span class="function">input</span>(<span class="string">"What is your superpower? "</span>)</code></pre>
  <p>Then include them in the first_message content so the AI knows about them!</p>
</div>

<div class="box box-orange">
  <div class="box-title">🏆 Challenge: Add a Score System</div>
  <p>Create a variable called <code>score = 0</code> at the beginning. Modify the system message to tell the AI to include score changes in the story like &#8220;+10 points for bravery!&#8221; Then use Python to track and display the running score.</p>
</div>

<!-- COMPLETE CODE -->
<h1>Complete Code (All Together)</h1>

<p>Here is the entire program in one place. If you got lost during the steps, use this as a reference. Remember to replace <code>paste-your-api-key-here</code> with your real API key from <a href="https://www.sekol.ninja" target="_blank">www.sekol.ninja</a>.</p>

<pre><code><span class="comment"># ============================================</span>
<span class="comment"># CHOOSE YOUR OWN ADVENTURE</span>
<span class="comment"># Powered by AI (ChatGPT)</span>
<span class="comment"># ============================================</span>

<span class="comment"># Import the library we need</span>
<span class="keyword">from</span> openai <span class="keyword">import</span> OpenAI

<span class="comment"># Set up the connection to ChatGPT</span>
<span class="comment"># Get your API key from www.sekol.ninja</span>
client = OpenAI(api_key=<span class="string">"paste-your-api-key-here"</span>)

<span class="comment"># Tell the AI what kind of stories to create</span>
system_message = {
    <span class="string">"role"</span>: <span class="string">"system"</span>,
    <span class="string">"content"</span>: <span class="string">"""You are an adventure story master for kids.
You create exciting choose-your-own-adventure stories.

RULES:
- Keep the story fun, exciting, and kid-friendly.
- Each response should be 2-3 short paragraphs.
- Always end with exactly 3 numbered choices for what to do next.
- Use vivid descriptions to make the story come alive.
- The story should have a sci-fi space adventure theme.
- Never include anything scary, violent, or inappropriate."""</span>
}

<span class="comment"># Create a list to keep track of the conversation</span>
conversation = [system_message]

<span class="comment"># Print the welcome screen</span>
<span class="function">print</span>(<span class="string">"="</span> * <span class="number">50</span>)
<span class="function">print</span>(<span class="string">"  CHOOSE YOUR OWN ADVENTURE"</span>)
<span class="function">print</span>(<span class="string">"  Powered by AI"</span>)
<span class="function">print</span>(<span class="string">"="</span> * <span class="number">50</span>)
<span class="function">print</span>()

<span class="comment"># Ask the player for their name</span>
player_name = <span class="function">input</span>(<span class="string">"Enter your character's name: "</span>)
<span class="function">print</span>()
<span class="function">print</span>(<span class="string">"Welcome, "</span> + player_name + <span class="string">"! Your adventure begins..."</span>)
<span class="function">print</span>()

<span class="comment"># Create the first message to start the story</span>
first_message = {
    <span class="string">"role"</span>: <span class="string">"user"</span>,
    <span class="string">"content"</span>: <span class="string">"Start a new adventure story. My character's name is "</span> + player_name + <span class="string">". Begin the story!"</span>
}
conversation.append(first_message)

<span class="comment"># The game loop</span>
<span class="keyword">while</span> True:
    <span class="comment"># Send the conversation to ChatGPT</span>
    response = client.chat.completions.create(
        model=<span class="string">"gpt-4o-mini"</span>,
        messages=conversation
    )

    <span class="comment"># Get the AI's story text</span>
    story_text = response.choices[<span class="number">0</span>].message.content

    <span class="comment"># Save the response to conversation history</span>
    conversation.append({
        <span class="string">"role"</span>: <span class="string">"assistant"</span>,
        <span class="string">"content"</span>: story_text
    })

    <span class="comment"># Display the story</span>
    <span class="function">print</span>(story_text)
    <span class="function">print</span>()

    <span class="comment"># Ask what the player wants to do</span>
    choice = <span class="function">input</span>(<span class="string">"What do you choose? (1, 2, 3, or 'quit'): "</span>)

    <span class="comment"># If they type quit, end the game</span>
    <span class="keyword">if</span> choice.lower() == <span class="string">"quit"</span>:
        <span class="function">print</span>()
        <span class="function">print</span>(<span class="string">"Thanks for playing, "</span> + player_name + <span class="string">"!"</span>)
        <span class="function">print</span>(<span class="string">"May the Code be with you!"</span>)
        <span class="keyword">break</span>

    <span class="comment"># Send the player's choice to the AI</span>
    conversation.append({
        <span class="string">"role"</span>: <span class="string">"user"</span>,
        <span class="string">"content"</span>: <span class="string">"I choose option "</span> + choice
    })

    <span class="function">print</span>()
    <span class="function">print</span>(<span class="string">"Generating next chapter..."</span>)
    <span class="function">print</span>()</code></pre>

<div class="hero-section" style="margin-top: 40px !important; padding: 25px !important;">
  <p style="font-size: 1.3em !important; margin: 0 !important;"><em>May the Code be with you!</em></p>
</div>

</div>
</body>
</html>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Installing Visual Studio Code on a Raspberry Pi for Python Development</title>
		<link>https://sekol.ninja/installing-visual-studio-code-on-a-raspberry-pi-for-python-development/</link>
		
		<dc:creator><![CDATA[Michael Sekol]]></dc:creator>
		<pubDate>Tue, 09 Jun 2026 16:52:48 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Install on Raspberry Pi]]></category>
		<category><![CDATA[Install Software]]></category>
		<category><![CDATA[VC Code for Raspberry Pi]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<guid isPermaLink="false">https://sekol.ninja/?p=10624</guid>

					<description><![CDATA[A Beginner-Friendly, Step-by-Step Guide Introduction If you have ever opened your Raspberry Pi&#8217;s Programming menu, you probably noticed an application called Thonny [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">A Beginner-Friendly, Step-by-Step Guide</p>



<!-- ── Introduction ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Introduction</h2>

<p style="margin-bottom:1.2em !important;">If you have ever opened your Raspberry Pi&#8217;s Programming menu, you probably noticed an application called <strong>Thonny</strong> already sitting there, ready to go. Thonny is a simple Python editor that ships with Raspberry Pi OS, and for absolute beginners writing their very first lines of Python, it does the job. It has a big Run button, a built-in shell, and almost nothing else to distract you.</p>

<p style="margin-bottom:1.2em !important;">So why would you bother installing something different?</p>

<p style="margin-bottom:1.2em !important;">The short answer is that Thonny is a <em>learning tool</em>, and Visual Studio Code (VS Code) is a <em>professional development environment</em>. The gap between the two is significant, and the sooner you make the switch, the sooner you start building the habits and skills that carry over into real-world software development.</p>

<!-- ── What Is VS Code ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">What Is Visual Studio Code?</h2>

<p style="margin-bottom:1.2em !important;">Visual Studio Code is a free, open-source code editor created by Microsoft. It runs on Windows, macOS, and Linux, which means it also runs on Raspberry Pi OS (a Debian-based Linux distribution). Despite being free, it is the most popular code editor in the world, used by millions of professional developers every day.</p>

<p style="margin-bottom:1.2em !important;">VS Code is <strong>not</strong> the same thing as Visual Studio (the full IDE). Think of VS Code as a lightweight, fast editor that you can customize with extensions to support almost any programming language, framework, or workflow you can imagine. It starts small and grows with you.</p>

<!-- ── Why VS Code ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Why VS Code Instead of Thonny?</h2>

<p style="margin-bottom:1.2em !important;">Thonny was designed to teach beginners the basics of Python. That narrow focus is both its strength and its limitation. Here is what Thonny <strong>does not</strong> give you:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;"><strong>No IntelliSense or intelligent code completion.</strong> Thonny offers basic autocomplete, but it cannot predict what you need or show you function signatures and documentation as you type.</li>
<li style="margin-bottom:0.6em !important;"><strong>No built-in terminal.</strong> Professional developers run commands, install packages, and manage files from inside their editor. Thonny keeps you locked into its own shell.</li>
<li style="margin-bottom:0.6em !important;"><strong>No extension ecosystem.</strong> You cannot add Git integration, linters, formatters, database viewers, or support for other languages.</li>
<li style="margin-bottom:0.6em !important;"><strong>No multi-file project support.</strong> Real projects are made of many files organized in folders. Thonny is built around editing one file at a time.</li>
<li style="margin-bottom:0.6em !important;"><strong>No integrated debugging for complex projects.</strong> Thonny has a basic debugger, but it lacks breakpoint conditions, watch expressions, and call stack navigation.</li>
</ul>

<p style="margin-bottom:1.2em !important;">VS Code solves all of these problems and adds capabilities you didn&#8217;t know you needed:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;"><strong>IntelliSense</strong> provides real-time code suggestions, function signatures, parameter hints, and inline documentation as you type.</li>
<li style="margin-bottom:0.6em !important;"><strong>Integrated terminal</strong> lets you run Python scripts, install packages with pip, and use Git without leaving the editor.</li>
<li style="margin-bottom:0.6em !important;"><strong>Extensions</strong> let you add Python linting (Pylint, Flake8), auto-formatting (Black, autopep8), Git visualization (GitLens), and thousands more with a single click.</li>
<li style="margin-bottom:0.6em !important;"><strong>Project-aware file explorer</strong> shows your entire project folder tree in a sidebar, making it easy to navigate between files.</li>
<li style="margin-bottom:0.6em !important;"><strong>Professional debugging</strong> with breakpoints, conditional breakpoints, variable inspection, call stacks, and a debug console.</li>
<li style="margin-bottom:0.6em !important;"><strong>Built-in Git support</strong> for version control, viewing diffs, staging changes, and committing code directly from the sidebar.</li>
<li style="margin-bottom:0.6em !important;"><strong>Industry standard</strong> &mdash; learning VS Code now means you already know the tool used at most tech companies, bootcamps, and universities.</li>
</ul>

<!-- Concept callout: Bottom Line -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4A1; Bottom Line</strong></p>
<p style="margin:0 !important;">Thonny is training wheels. VS Code is the bicycle. Both serve a purpose, but you will go much further and much faster once you make the switch. Everything you learn in VS Code on your Raspberry Pi transfers directly to any other computer or operating system.</p>
</div>
</div>

<!-- ── Prerequisites ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Prerequisites</h2>

<p style="margin-bottom:1.2em !important;">Before you begin, make sure you have the following:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;"><strong>Raspberry Pi 4</strong> (4 GB or more recommended) <strong>or Raspberry Pi 5</strong></li>
<li style="margin-bottom:0.6em !important;"><strong>Raspberry Pi OS</strong> installed and working</li>
<li style="margin-bottom:0.6em !important;"><strong>An active internet connection</strong></li>
<li style="margin-bottom:0.6em !important;"><strong>A keyboard, mouse, and monitor</strong> connected to the Pi</li>
</ul>

<!-- Note callout -->
<div style="display:flex;border:1px solid #E65100;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#E65100;"></div>
<div style="background:#FFF3E0;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#E65100;">&#x26A0;&#xFE0F; Note</strong></p>
<p style="margin:0 !important;">VS Code is a full desktop application, and it runs best on a Raspberry Pi 4 or 5 with at least 4 GB of RAM. Older models or 1 GB/2 GB boards may struggle with performance.</p>
</div>
</div>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 1 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 1: Update the Operating System</h2>

<p style="margin-bottom:1.2em !important;">Before installing any new software, you should always update your operating system first. Updates ensure you have the latest security patches, bug fixes, and package information. If you skip this step, you might install an outdated version of a program, or the installation might fail entirely because your system does not know where to find the latest packages.</p>

<p style="margin-bottom:1.2em !important;">Open a Terminal window (you can find it in the taskbar at the top of the screen or in the Accessories menu) and type the following commands one at a time, pressing Enter after each one:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">sudo apt update
sudo apt full-upgrade -y
sudo reboot</pre>

<!-- Concept callout: command explanation -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4D6; What Do These Commands Mean?</strong></p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>sudo</code></strong> stands for &#8220;Superuser Do.&#8221; It gives you temporary administrator (root) privileges to make system-level changes. Without <code>sudo</code>, the system would block you from installing or updating software because those actions affect all users on the machine.</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>apt</code></strong> stands for &#8220;Advanced Package Tool.&#8221; It is the package manager for Debian-based Linux systems like Raspberry Pi OS. Think of it as an app store you control from the command line. It knows how to download, install, update, and remove software packages.</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>apt update</code></strong> tells apt to refresh its list of available software and versions from the internet. It does not install anything &mdash; it just checks what is available.</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>apt full-upgrade -y</code></strong> downloads and installs all available updates for every package on your system. The <code>-y</code> flag means &#8220;yes to all prompts,&#8221; so you do not have to confirm each update manually.</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>reboot</code></strong> restarts the Raspberry Pi so that any kernel or system-level updates take effect.</p>
</div>
</div>

<p style="margin-bottom:1.2em !important;">Wait for the Raspberry Pi to restart and log back in before continuing.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 2 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 2: Verify Your Raspberry Pi Model</h2>

<p style="margin-bottom:1.2em !important;">This is an optional but helpful step. You can check exactly which Raspberry Pi model you are using by running:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">cat /proc/device-tree/model</pre>

<p style="margin-bottom:1.2em !important;">You should see output similar to this:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">Raspberry Pi 5 Model B Rev 1.0</pre>

<!-- Concept callout -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4D6; What Does This Command Mean?</strong></p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>cat</code></strong> is short for &#8220;concatenate.&#8221; It is a command that reads a file and prints its contents to the screen. In this case, the file <code>/proc/device-tree/model</code> is a special system file that stores your Pi&#8217;s hardware identity. You are not opening a normal document &mdash; you are asking Linux to tell you what hardware it is running on.</p>
</div>
</div>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 3 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 3: Install Visual Studio Code</h2>

<p style="margin-bottom:1.2em !important;">Now that your system is up to date, you can install VS Code. Raspberry Pi OS includes VS Code in its official software repositories, so the installation is a single command:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">sudo apt install code -y</pre>

<!-- Concept callout -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4D6; What Does This Command Mean?</strong></p>
<p style="margin:0.8em 0 0 0 !important;">You already know <code>sudo</code> (run as administrator) and <code>apt</code> (the package manager). The word <strong><code>install</code></strong> tells apt you want to add new software. The word <strong><code>code</code></strong> is the package name for Visual Studio Code in the Raspberry Pi OS repository. Finally, the <code>-y</code> flag automatically answers &#8220;yes&#8221; to any confirmation prompts so the installation proceeds without interruption.</p>
</div>
</div>

<p style="margin-bottom:1.2em !important;">The installation will take a minute or two depending on your internet speed. When it finishes, VS Code is ready to use.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 4 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 4: Launch Visual Studio Code</h2>

<p style="margin-bottom:1.2em !important;">You can start VS Code in two ways:</p>

<h3 style="color:#555;margin-top:1.5em !important;margin-bottom:0.6em !important;">Option A: From the Terminal</h3>

<p style="margin-bottom:1.2em !important;">Type the following command and press Enter:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">code</pre>

<h3 style="color:#555;margin-top:1.5em !important;margin-bottom:0.6em !important;">Option B: From the Desktop Menu</h3>

<p style="margin-bottom:1.2em !important;">Click the Raspberry Pi menu icon in the top-left corner of your screen, navigate to <strong>Programming</strong>, and click <strong>Visual Studio Code</strong>.</p>

<p style="margin-bottom:1.2em !important;">Either method opens the same application. When VS Code launches for the first time, you will see a Welcome tab with helpful links and tips. Feel free to explore it or close it.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 5 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 5: Install the Python Extension</h2>

<p style="margin-bottom:1.2em !important;">Out of the box, VS Code is a general-purpose editor. To unlock its full Python capabilities, you need to install the official Python extension. This is what transforms VS Code from a plain text editor into a Python powerhouse.</p>

<ol style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;">Open Visual Studio Code.</li>
<li style="margin-bottom:0.6em !important;">Click the <strong>Extensions</strong> icon on the left sidebar. It looks like four small squares with one square detached.</li>
<li style="margin-bottom:0.6em !important;">In the search bar at the top, type <strong>Python</strong>.</li>
<li style="margin-bottom:0.6em !important;">Find the extension called <strong>Python</strong> published by <strong>Microsoft</strong> (it will be the first result with millions of installs). Click <strong>Install</strong>.</li>
</ol>

<p style="margin-bottom:1.2em !important;">Once installed, this extension provides:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;"><strong>Syntax highlighting</strong> &mdash; Python keywords, strings, and functions are displayed in different colors so your code is easier to read.</li>
<li style="margin-bottom:0.6em !important;"><strong>Code completion (IntelliSense)</strong> &mdash; as you type, VS Code suggests variable names, functions, and methods with documentation popups.</li>
<li style="margin-bottom:0.6em !important;"><strong>Debugging tools</strong> &mdash; set breakpoints, step through code line by line, and inspect variables in real time.</li>
<li style="margin-bottom:0.6em !important;"><strong>Virtual environment support</strong> &mdash; VS Code detects and activates Python virtual environments automatically.</li>
<li style="margin-bottom:0.6em !important;"><strong>Code navigation</strong> &mdash; jump to function definitions, find all references, and rename variables across your entire project.</li>
</ul>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 6 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 6: Verify Python Is Installed</h2>

<p style="margin-bottom:1.2em !important;">Raspberry Pi OS comes with Python pre-installed, but it is good practice to verify the version. Open a Terminal and run:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">python3 --version</pre>

<p style="margin-bottom:1.2em !important;">You should see output like this:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">Python 3.11.x</pre>

<p style="margin-bottom:1.2em !important;">The exact version number may vary depending on your Raspberry Pi OS version. As long as you see Python 3.x, you are good to go.</p>

<!-- Tip callout -->
<div style="display:flex;border:1px solid #00796B;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#00796B;"></div>
<div style="background:#E0F2F1;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#00796B;">&#x1F4A1; Tip</strong></p>
<p style="margin:0 !important;">On Raspberry Pi OS, always use the command <code>python3</code>, not <code>python</code>. Some Linux systems still associate the plain <code>python</code> command with the older Python 2, which is no longer maintained.</p>
</div>
</div>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 7 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 7: Create a Test Project</h2>

<p style="margin-bottom:1.2em !important;">Let&#8217;s create a simple project folder and a Python file to make sure everything is working. In your Terminal, run the following commands:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">mkdir ~/python-test
cd ~/python-test</pre>

<!-- Concept callout -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4D6; What Do These Commands Mean?</strong></p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>mkdir</code></strong> stands for &#8220;make directory.&#8221; It creates a new folder. The <code>~</code> symbol (called a tilde) is a shortcut that means &#8220;my home folder.&#8221; So <code>mkdir ~/python-test</code> creates a folder called <code>python-test</code> inside your home directory.</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>cd</code></strong> stands for &#8220;change directory.&#8221; It moves you into the folder you just created. After running <code>cd</code>, any files you create will be saved inside that folder.</p>
</div>
</div>

<p style="margin-bottom:1.2em !important;">Now create a Python file using the nano text editor:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">nano hello.py</pre>

<p style="margin-bottom:1.2em !important;">This opens a simple text editor inside the Terminal. Type the following line of Python code:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">print("Hello from Raspberry Pi!")</pre>

<p style="margin-bottom:1.2em !important;">Save and close the file:</p>

<ol style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;">Press <strong>Ctrl + O</strong> (that is the letter O, not zero) to save.</li>
<li style="margin-bottom:0.6em !important;">Press <strong>Enter</strong> to confirm the filename.</li>
<li style="margin-bottom:0.6em !important;">Press <strong>Ctrl + X</strong> to exit nano.</li>
</ol>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 8 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 8: Open the Project in VS Code</h2>

<p style="margin-bottom:1.2em !important;">Now open your project folder in VS Code. From your Terminal, run:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">code ~/python-test</pre>

<p style="margin-bottom:1.2em !important;">VS Code will open with your <code>python-test</code> folder loaded in the sidebar. You should see your <code>hello.py</code> file listed. Click on it to open it in the editor.</p>

<!-- Tip callout -->
<div style="display:flex;border:1px solid #00796B;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#00796B;"></div>
<div style="background:#E0F2F1;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#00796B;">&#x1F4A1; Tip</strong></p>
<p style="margin:0 !important;">Always open a <em>folder</em> in VS Code rather than individual files. When VS Code has a folder open, it can detect virtual environments, find related files, provide better IntelliSense, and use project-level settings.</p>
</div>
</div>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 9 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 9: Select the Python Interpreter</h2>

<p style="margin-bottom:1.2em !important;">VS Code needs to know which Python installation to use. This is called selecting the <strong>interpreter</strong>.</p>

<ol style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;">Press <strong>Ctrl + Shift + P</strong> to open the Command Palette. This is a search bar that lets you find any VS Code command.</li>
<li style="margin-bottom:0.6em !important;">Type <strong>Python: Select Interpreter</strong> and click the matching option.</li>
<li style="margin-bottom:0.6em !important;">Select <code>/usr/bin/python3</code> from the list. If you have a virtual environment set up (covered later in this guide), you can choose that instead.</li>
</ol>

<p style="margin-bottom:1.2em !important;">Once selected, VS Code will display the interpreter in the bottom status bar so you always know which Python version your project is using.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Step 10 ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Step 10: Run the Program</h2>

<h3 style="color:#555;margin-top:1.5em !important;margin-bottom:0.6em !important;">Option A: Using VS Code</h3>

<p style="margin-bottom:1.2em !important;">With <code>hello.py</code> open in the editor, click the <strong>Run</strong> button (the &#x25B6; play icon) in the upper-right corner of the editor. VS Code will open its built-in terminal at the bottom of the screen and run your script.</p>

<h3 style="color:#555;margin-top:1.5em !important;margin-bottom:0.6em !important;">Option B: Using the Terminal</h3>

<p style="margin-bottom:1.2em !important;">If you prefer, you can run the script directly from any Terminal window:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">python3 hello.py</pre>

<p style="margin-bottom:1.2em !important;">Either way, you should see the following output:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">Hello from Raspberry Pi!</pre>

<!-- Checkpoint callout -->
<div style="display:flex;border:1px solid #2E7D32;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#2E7D32;"></div>
<div style="background:#E8F5E9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#2E7D32;">&#x2705; Checkpoint</strong></p>
<p style="margin:0 !important;">If you see the message above, congratulations! You have successfully installed VS Code, configured it for Python, and run your first program. The remaining sections are optional but highly recommended.</p>
</div>
</div>

<hr style="border:none;border-top:2px solid #2E75B6;margin:2.5em 0 !important;">

<!-- ── Optional: Virtual Environment ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Optional: Create a Virtual Environment</h2>

<p style="margin-bottom:1.2em !important;">A virtual environment is an isolated copy of Python that lives inside your project folder. It lets you install packages for one project without affecting any other project or the system-wide Python installation. This is considered a best practice in Python development.</p>

<p style="margin-bottom:1.2em !important;">First, install the virtual environment package:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">sudo apt install python3-venv -y</pre>

<p style="margin-bottom:1.2em !important;">Then create and activate a virtual environment inside your project folder:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">cd ~/python-test
python3 -m venv .venv
source .venv/bin/activate</pre>

<!-- Concept callout -->
<div style="display:flex;border:1px solid #7B2D8E;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#7B2D8E;"></div>
<div style="background:#F3E8F9;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#7B2D8E;">&#x1F4D6; What Do These Commands Mean?</strong></p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>python3 -m venv .venv</code></strong> tells Python to run its built-in <code>venv</code> module and create a virtual environment in a hidden folder called <code>.venv</code> inside your project directory. The dot at the beginning of <code>.venv</code> makes it a hidden folder in Linux (it will not clutter your file listing).</p>
<p style="margin:0.8em 0 0 0 !important;"><strong><code>source .venv/bin/activate</code></strong> runs the activation script. After activation, your terminal prompt will change to show <code>(.venv)</code> at the beginning, which tells you the virtual environment is active. Any <code>pip install</code> commands you run now will install packages only inside this environment.</p>
</div>
</div>

<p style="margin-bottom:1.2em !important;">You should see your terminal prompt change to something like:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">(.venv) pi@raspberrypi:~/python-test $</pre>

<p style="margin-bottom:1.2em !important;">Now you can install packages safely. For example:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">pip install requests</pre>

<p style="margin-bottom:1.2em !important;">VS Code will usually detect the virtual environment automatically and ask if you want to use it as your interpreter. Click <strong>Yes</strong> when prompted.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Optional: Git ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Optional: Install Git</h2>

<p style="margin-bottom:1.2em !important;">Git is a version control system that tracks changes to your code over time. It lets you save snapshots of your project, undo mistakes, collaborate with others, and share your code on platforms like GitHub. If you are learning to code, learning Git early is one of the best investments you can make.</p>

<p style="margin-bottom:1.2em !important;">Install Git:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">sudo apt install git -y</pre>

<p style="margin-bottom:1.2em !important;">Configure your identity (Git uses this to label your commits):</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">git config --global user.name "Your Name"
git config --global user.email "you@example.com"</pre>

<p style="margin-bottom:1.2em !important;">Verify the installation:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">git --version</pre>

<p style="margin-bottom:1.2em !important;">You should see output like:</p>

<pre style="background:#F0F0F0;border:1px solid #CCC;border-radius:4px;padding:14px 18px !important;font-family:'Consolas','Courier New',monospace;font-size:0.95em;line-height:1.6;overflow-x:auto;margin-bottom:1.2em !important;">git version 2.39.x</pre>

<p style="margin-bottom:1.2em !important;">Once Git is installed, VS Code&#8217;s built-in <strong>Source Control</strong> panel (the branch icon on the left sidebar) will automatically detect Git repositories and let you stage, commit, and push changes without leaving the editor.</p>

<hr style="border:none;border-top:1px solid #ddd;margin:2.5em 0 !important;">

<!-- ── Recommended Extensions ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Recommended VS Code Extensions</h2>

<p style="margin-bottom:1.2em !important;">Now that VS Code is set up, here are some extensions worth installing from the Extensions marketplace to further improve your workflow:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;"><strong>Python</strong> (Microsoft) &mdash; the core extension you already installed. Provides IntelliSense, debugging, and environment management.</li>
<li style="margin-bottom:0.6em !important;"><strong>Pylance</strong> (Microsoft) &mdash; a faster, more powerful Python language server that improves type checking, auto-imports, and code navigation. It is often installed automatically alongside the Python extension.</li>
<li style="margin-bottom:0.6em !important;"><strong>GitHub Pull Requests and Issues</strong> (GitHub) &mdash; if you use GitHub, this extension lets you create pull requests, review code, and manage issues directly inside VS Code.</li>
<li style="margin-bottom:0.6em !important;"><strong>GitLens</strong> (GitKraken) &mdash; adds powerful Git annotations, blame info, and history visualization so you can see who changed what and when.</li>
<li style="margin-bottom:0.6em !important;"><strong>Docker</strong> (Microsoft) &mdash; optional. If you work with containers, this extension makes managing Docker images and containers much easier.</li>
</ul>

<hr style="border:none;border-top:2px solid #2E75B6;margin:2.5em 0 !important;">

<!-- ── Summary ── -->

<h2 style="color:#2E75B6;margin-top:2em !important;margin-bottom:0.8em !important;">Summary</h2>

<p style="margin-bottom:1.2em !important;">After completing this guide, your Raspberry Pi now has:</p>

<ul style="margin-top:0.8em !important;margin-bottom:1.2em !important;">
<li style="margin-bottom:0.6em !important;">Visual Studio Code installed and configured</li>
<li style="margin-bottom:0.6em !important;">The Python extension providing IntelliSense, debugging, and code navigation</li>
<li style="margin-bottom:0.6em !important;">A verified Python installation ready for development</li>
<li style="margin-bottom:0.6em !important;">Optional virtual environment support for isolated project dependencies</li>
<li style="margin-bottom:0.6em !important;">Optional Git integration for version control</li>
</ul>

<p style="margin-bottom:1.2em !important;">This setup closely mirrors the environment used by professional Python developers working on Linux servers, cloud systems, and production applications. Everything you learn here transfers directly to any computer running VS Code, regardless of operating system.</p>

<!-- Tip callout: What's Next -->
<div style="display:flex;border:1px solid #00796B;border-radius:4px;overflow:hidden;margin:1.5em 0 !important;">
<div style="width:6px;min-width:6px;background:#00796B;"></div>
<div style="background:#E0F2F1;padding:16px 20px !important;flex:1;">
<p style="margin:0 0 0.5em 0 !important;"><strong style="color:#00796B;">&#x1F680; What&#8217;s Next?</strong></p>
<p style="margin:0 !important;">Start building! Open VS Code, create a new Python file, and write something. Experiment with the IntelliSense suggestions, try setting a breakpoint, and explore the integrated terminal. The best way to learn a tool is to use it.</p>
</div>
</div>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: sekol.ninja @ 2026-09-06 10:51:17 by W3 Total Cache
-->