Ai Coding Tools

How to Write Python Code Using GitHub Copilot in 30 Minutes

By BTW Team3 min read

How to Write Python Code Using GitHub Copilot in 30 Minutes

If you've ever stared at a blank screen, grappling with how to start writing Python code, you're not alone. As indie hackers and solo founders, we often find ourselves juggling multiple roles, and coding should be as efficient as possible. Enter GitHub Copilot, an AI-powered coding assistant that can help you write Python code faster and with fewer headaches. In this guide, I’ll walk you through how to leverage Copilot effectively in just 30 minutes.

Prerequisites: What You Need

Before diving in, here’s what you need to get started:

  • GitHub Account: You’ll need to sign up for GitHub (free).
  • Visual Studio Code (VS Code): Download and install VS Code.
  • GitHub Copilot Subscription: Copilot costs $10/month after a free trial. You'll need to set this up in your GitHub account.
  • Basic Python Knowledge: Familiarity with Python syntax and concepts will help, but Copilot can assist even if you're a beginner.

Step 1: Setting Up GitHub Copilot

  1. Install the GitHub Copilot Extension:

    • Open VS Code.
    • Go to the Extensions view (Ctrl + Shift + X).
    • Search for “GitHub Copilot” and click “Install”.
  2. Sign In:

    • After installation, you’ll be prompted to sign in to your GitHub account.
    • Follow the instructions to authorize Copilot.
  3. Configure Settings:

    • Navigate to settings (File > Preferences > Settings).
    • Search for “Copilot” and adjust preferences as needed, such as enabling inline suggestions.

Step 2: Writing Your First Python Function

Example Task: Create a Simple Calculator

  1. Open a New Python File:

    • Create a new file called calculator.py.
  2. Start Coding:

    • Type a comment describing the function you want to create. For example:
      # Create a function to add two numbers
      
    • Wait a moment for Copilot to suggest code. You should see a suggestion pop up.
  3. Accept Suggestions:

    • If the suggestion looks good, press Tab to accept it. If not, you can cycle through suggestions using Ctrl + ] or Ctrl + [.
  4. Test the Function:

    • After writing your function, add a test case:
      print(add(5, 3))  # Expected output: 8
      

Expected Output:

When you run the file using python calculator.py, you should see the output:

8

Step 3: Iterating on Your Code

After your initial function, you might want to expand your calculator. Simply describe what you want in comments, and Copilot will provide suggestions. For example, to create a subtraction function, type:

# Create a function to subtract two numbers

Then accept the suggestion and test it similarly.

Troubleshooting: What Could Go Wrong

  • No Suggestions Appearing: Ensure you’re connected to the internet and logged into GitHub. Restarting VS Code can sometimes resolve this.
  • Irrelevant Suggestions: Copilot learns from context, so provide clear comments and structure in your code to improve suggestions.

What's Next: Building a Full Application

Once you’re comfortable with writing functions, consider building a more complex application. Perhaps a command-line interface (CLI) for your calculator or even integrating it with a web framework like Flask. Copilot can assist with these tasks as well.

Conclusion: Start Here

Using GitHub Copilot can significantly speed up your coding process, especially for indie hackers and solo founders. With just a bit of setup and some basic Python knowledge, you can harness the power of AI to write code faster and more efficiently.

What We Actually Use

In our experience, GitHub Copilot is essential for speeding up repetitive coding tasks. While it’s not perfect and occasionally makes odd suggestions, it’s a tool that has saved us countless hours.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

5 Common Misconceptions About AI Coding Tools That Will Hurt Your Learning

5 Common Misconceptions About AI Coding Tools That Will Hurt Your Learning As a beginner in coding, diving into the world of AI coding tools can feel like stepping into a futuristi

Oct 6, 20263 min read
Ai Coding Tools

10 AI Coding Tools Beginners Overlook in 2026

10 AI Coding Tools Beginners Overlook in 2026 As a beginner in coding, diving into the vast ocean of AI tools can feel overwhelming. While flashy tools often grab the spotlight, ma

Oct 6, 20265 min read
Ai Coding Tools

5 Common Misconceptions About AI Coding Tools That Beginners Believe

5 Common Misconceptions About AI Coding Tools That Beginners Believe As a solo founder or indie hacker, diving into the world of AI coding tools can feel overwhelming, especially i

Oct 5, 20263 min read
Ai Coding Tools

5 Mistakes Every Beginner Makes When Using AI Coding Tools

5 Mistakes Every Beginner Makes When Using AI Coding Tools As a solo founder or indie hacker diving into the world of AI coding tools, it’s easy to get swept up in the excitement o

Oct 4, 20264 min read
Ai Coding Tools

10 Common Misconceptions About AI Coding Tools in 2026

10 Common Misconceptions About AI Coding Tools in 2026 As we dive into 2026, AI coding tools have become a staple in the developer toolkit. However, misconceptions still run rampan

Oct 4, 20264 min read
Ai Coding Tools

5 Mistakes to Avoid When Using AI Coding Tools for Real Projects

5 Mistakes to Avoid When Using AI Coding Tools for Real Projects As we dive deeper into 2026, AI coding tools have become an essential part of the developer's toolkit. However, usi

Oct 4, 20264 min read