Ai Coding Tools

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

By BTW Team4 min read

How to Use AI Tools to Write Your First Python Program in 2 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.

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 Mistakes Developers Make When Using AI Coding Tools in 2026

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026 As AI coding tools have become an integral part of a developer's toolkit in 2026, many are still stumbling over

Oct 12, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026 As we dive into 2026, the landscape of AI coding tools has evolved significantly, yet many developers still

Oct 11, 20263 min read
Ai Coding Tools

Why AI Coding Assistants Are Overrated for Beginners in 2026

Why AI Coding Assistants Are Overrated for Beginners in 2026 As a solo founder or indie hacker, it’s tempting to think that AI coding assistants are the silver bullet to jumpstart

Oct 10, 20263 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for Beginners

10 Common Mistakes When Using AI Coding Tools for Beginners As a beginner in coding, diving into AI coding tools can feel like a doubleedged sword. On one hand, these tools promise

Oct 8, 20264 min read
Ai Coding Tools

5 Common Misconceptions About AI Coding Tools and Why They Hold You Back

5 Common Misconceptions About AI Coding Tools and Why They Hold You Back As a solo founder or indie hacker, you might be considering leveraging AI coding tools to boost your produc

Oct 7, 20264 min read
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