Ai Coding Tools

How to Use AI Tools to Write Your First Python Program in 2 Hours

By BTW Team4 min read

Comparing tools? See the AI tools tested on the show.

In short

Step-by-step tutorial that guides you through leveraging AI coding tools to create a simple Python program in just two hours.

Feeling overwhelmed by the prospect of writing your first Python program? You're not alone. Many aspiring coders get stuck in the endless loop of tutorials and documentation, unsure where to start. In 2026, AI tools have made it easier than ever to break through that barrier and actually write code. In this guide, I’ll show you how to leverage AI tools to write your first Python program in just 2 hours.

Prerequisites: What You Need to Get Started

Before diving in, here’s what you’ll need:

  1. A Computer: Any machine that can run Python will do.
  2. Python Installed: Download the latest version here.
  3. An AI Tool: We’ll look at several options below, such as GitHub Copilot or OpenAI's Codex.
  4. A Code Editor: Visual Studio Code or PyCharm are both solid choices.

Step 1: Choose Your AI Tool

Let’s explore some AI tools that can assist you in writing Python code. Knowing what each tool does, its pricing, and its limitations will help you make the right choice.

AI Tools Overview

| Tool | What It Does | Pricing | Best For | Limitations | Our Take | |----------------------|---------------------------------------------|------------------------------|------------------------------|------------------------------------------|--------------------------------------------| | GitHub Copilot | AI-powered code completion for various languages | $10/mo, no free tier | Beginners looking for guidance | Can suggest incorrect code | We use this for quick code suggestions. | | OpenAI Codex | Natural language to code conversion | $0-100/mo based on usage | Building small scripts | Usage limits can add up | Great for generating snippets quickly. | | Replit | Collaborative online IDE with AI support | Free tier + $20/mo pro | Beginners and team projects | Limited features in free tier | We like it for collaborative projects. | | Tabnine | AI code completion for multiple languages | Free tier + $12/mo pro | Individual developers | Less robust than Copilot | Good for simple auto-completions. | | Codeium | Free AI-powered code completion | Free | Students and hobbyists | Fewer advanced features | Excellent for those on a budget. | | Sourcery | AI-powered code review and suggestions | Free tier + $15/mo pro | Developers wanting to refactor | Limited to Python only | We don’t use this much personally. |

What We Actually Use

In our experience, GitHub Copilot is the most effective tool for beginners, while OpenAI Codex is excellent for translating ideas into code quickly.

Step 2: Define Your Project

Before you start writing code, decide on a simple project. A common choice for beginners is a basic calculator that can add, subtract, multiply, and divide. This project is straightforward and will give you a chance to use various Python concepts.

Step 3: Generate Code with AI

Now that you have your project defined, let’s use an AI tool to generate some code. Here’s a step-by-step process:

  1. Open your code editor and create a new Python file (e.g., calculator.py).
  2. Start with a comment that describes what you want to build. For example:
    # A simple calculator that can add, subtract, multiply, and divide.
    
  3. Use your AI tool to generate functions. For example, in GitHub Copilot, start typing:
    def add(x, y):
    
    The AI will suggest the rest of the code.
  4. Repeat for other operations (subtract, multiply, divide).
  5. Implement user input to allow users to choose an operation and enter numbers.

Expected Output

After generating the code, your calculator.py might look something like this:

def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

def multiply(x, y):
    return x * y

def divide(x, y):
    return x / y

print("Select operation:")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

choice = input("Enter choice (1/2/3/4): ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == '1':
    print(num1, "+", num2, "=", add(num1, num2))
# Add similar conditions for other operations

Troubleshooting: What Could Go Wrong

  1. AI Suggestions: Sometimes the AI might suggest incorrect syntax. Don’t hesitate to modify it.
  2. Errors: If your program throws an error, read the traceback carefully. It often tells you where you went wrong.

What’s Next?

Once you’ve built your calculator, consider expanding it by adding features like error handling, user-friendly messages, or even a graphical interface using libraries like Tkinter.

Conclusion: Start Here

If you're just starting out, I recommend beginning with GitHub Copilot for its intuitive suggestions. Follow the steps outlined above, and you’ll have your first Python program running in no time. Remember, the key is to experiment and not get discouraged by mistakes; every coder has been there.

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read