TutorialesTutorials · PrincipianteBeginner

Cómo programar en Python con IAHow to program in Python with AI

Aprende cómo programar en Python con IA desde cero: instala Python, elige tu herramienta (gratis o de pago) y escribe tu primer script con Claude o GitHub Copilot.Learn how to program in Python with AI from scratch: install Python, pick your tool (free or paid), and write your first script with Claude or GitHub Copilot.

  • Python
  • Claude
  • GitHub Copilot
  • VS Code

En esta guía vas a aprender cómo programar en Python con IA desde cero: instalarás Python en tu computadora, elegirás una herramienta de IA (gratuita o de pago) y escribirás tu primer script con ayuda de Claude o GitHub Copilot. No necesitas experiencia previa en programación.

Elige tu sistema (Windows o Mac) con los botones de arriba y toca cada paso para abrirlo.

In this guide you’ll learn how to program in Python with AI from scratch: you’ll install Python on your computer, pick an AI tool (free or paid), and write your first script with Claude or GitHub Copilot. No prior programming experience needed.

Pick your system (Windows or Mac) with the buttons above and tap each step to open it.

1 Instalar PythonInstall Python

Python es el lenguaje de programación que vamos a usar. Es gratuito.

  1. Entra a https://python.org/downloads
  2. El botón amarillo grande descarga la versión más reciente para tu sistema.
  1. Abre el archivo .exe descargado.
  2. Antes de hacer clic en “Install Now”, marca la casilla “Add Python to PATH” (importante: si no la marcas, el siguiente paso fallará).
  3. Haz clic en “Install Now” y espera a que termine.
  1. Abre el archivo .pkg descargado y sigue los pasos hasta “Cerrar”.

Para comprobar que funcionó: abre PowerShellla Terminal y escribe:

python --version
python3 --version

Si aparece un número como Python 3.12.0, ¡listo!

Python is the programming language we’ll use. It’s free.

  1. Go to https://python.org/downloads
  2. The big yellow button downloads the latest version for your system.
  1. Open the downloaded .exe file.
  2. Before clicking “Install Now”, check the “Add Python to PATH” box (important: if you skip this, the next step will fail).
  3. Click “Install Now” and wait for it to finish.
  1. Open the downloaded .pkg file and follow the steps until “Close”.

To check it worked: open PowerShellthe Terminal and type:

python --version
python3 --version

If you see a number like Python 3.12.0, you’re set!

2 Elegir tu herramienta de IAPick your AI tool

Tienes varias opciones, todas funcionan bien para aprender Python:

HerramientaPrecioCómo ayuda
GitHub Copilot Free$0Sugiere código mientras escribes en VS Code (autocompletado IA)
Claude (claude.ai)$0 (limitado)Chat: explica, escribe scripts completos y corrige errores
ChatGPT (chat.openai.com)$0 (limitado)Similar a Claude: explica y genera código por chat

Si quieres empezar gratis hoy: abre https://claude.ai en tu navegador y ya puedes pedirle código Python en el chat, sin instalar nada más.

Si quieres la experiencia completa en el editor: instala VS Code y agrega GitHub Copilot (Paso 3). El plan gratuito de Copilot cubre perfectamente el aprendizaje.

You have several options, all work well for learning Python:

ToolPriceHow it helps
GitHub Copilot Free$0Suggests code as you type in VS Code (AI autocomplete)
Claude (claude.ai)$0 (limited)Chat: explains, writes full scripts, and fixes errors
ChatGPT (chat.openai.com)$0 (limited)Similar to Claude: explains and generates code by chat

To start free today: open https://claude.ai in your browser and ask for Python code right in the chat, no extra setup needed.

For the full in-editor experience: install VS Code and add GitHub Copilot (Step 3). The free Copilot plan covers learning perfectly.

3 Instalar VS Code y GitHub CopilotInstall VS Code and GitHub Copilot

VS Code es el editor de código más popular y GitHub Copilot se integra directamente con él. El plan gratuito de Copilot incluye 2.000 completions y 50 chats por mes (confirma los límites actuales en https://github.com/features/copilot/plans).

  1. Instala VS Code desde https://code.visualstudio.com (gratis).
  2. Abre VS Code, ve al panel de Extensiones (Ctrl + Shift + XCmd + Shift + X) y busca GitHub Copilot. Instala la extensión oficial de GitHub.
  3. Se abrirá una ventana para iniciar sesión con tu cuenta de GitHub (créala gratis en https://github.com si no tienes).
  4. Al iniciar sesión, Copilot activa el plan gratuito automáticamente.

Ahora, cuando abras un archivo .py y empieces a escribir, Copilot mostrará sugerencias en gris. Aprieta Tab para aceptar.

¿Quieres la integración con Claude en vez de Copilot? Mira el tutorial Cómo conectar Claude a Visual Studio Code.

VS Code is the most popular code editor and GitHub Copilot integrates directly with it. The free Copilot plan includes 2,000 completions and 50 chats per month (confirm current limits at https://github.com/features/copilot/plans).

  1. Install VS Code from https://code.visualstudio.com (free).
  2. Open VS Code, go to the Extensions panel (Ctrl + Shift + XCmd + Shift + X) and search for GitHub Copilot. Install the official GitHub extension.
  3. A window will open to sign in with your GitHub account (create one free at https://github.com if you don’t have one).
  4. When you sign in, Copilot activates the free plan automatically.

Now, when you open a .py file and start typing, Copilot will show suggestions in gray. Press Tab to accept.

Want Claude integration instead of Copilot? See the tutorial How to connect Claude to Visual Studio Code.

4 Escribir tu primer script con IAWrite your first script with AI

El flujo básico para programar Python con IA es siempre el mismo: describir a la IA lo que quieres, copiar el código y ejecutarlo.

Opción A: por chat (Claude.ai o ChatGPT)

  1. Abre https://claude.ai en tu navegador.
  2. Escríbele, por ejemplo: “Escribe un script de Python que me salude por mi nombre y me diga qué día es hoy.”
  3. Claude te devuelve el código. Cópialo.
  4. Abre Bloc de notasTextEdit, pega el código y guárdalo como saludo.py (por ejemplo, en tu Escritorio).

Opción B: en VS Code con Copilot

  1. Crea un archivo nuevo en VS Code y guárdalo como saludo.py.
  2. Escribe un comentario describiendo lo que quieres: # Script que saluda por nombre y muestra la fecha de hoy
  3. Copilot sugiere el código a continuación. Aprieta Tab para aceptarlo.

Tanto por chat como con autocompletado, la IA genera el código por ti: tu trabajo es describir bien lo que quieres y ejecutarlo.

The basic flow for programming Python with AI is always the same: describe to the AI what you want, copy the code, and run it.

Option A: by chat (Claude.ai or ChatGPT)

  1. Open https://claude.ai in your browser.
  2. Type, for example: “Write a Python script that greets me by name and tells me what day it is.”
  3. Claude returns the code. Copy it.
  4. Open NotepadTextEdit, paste the code, and save it as saludo.py (on your Desktop, for example).

Option B: in VS Code with Copilot

  1. Create a new file in VS Code and save it as saludo.py.
  2. Type a comment describing what you want: # Script that greets by name and shows today's date
  3. Copilot suggests the code below. Press Tab to accept it.

Whether by chat or autocomplete, the AI generates the code for you: your job is to describe clearly what you want and run it.

5 Ejecutar tu scriptRun your script
  1. Abre PowerShellla Terminal.
  2. Navega hasta donde guardaste el archivo. Si lo guardaste en el Escritorio:
cd $HOME\Desktop
cd ~/Desktop
  1. Ejecuta el script:
python saludo.py
python3 saludo.py

Deberías ver el mensaje de saludo en la pantalla. ¡Acabas de ejecutar tu primer programa en Python con IA!

Si ves un error, no lo cierres: copia el mensaje completo y pégalo en el chat de Claude o ChatGPT. Pídeles: “Tengo este error al ejecutar mi script de Python, ¿qué está mal?”. Aprenderás más del error que del código perfecto.

  1. Open PowerShellthe Terminal.
  2. Navigate to where you saved the file. If you saved it on the Desktop:
cd $HOME\Desktop
cd ~/Desktop
  1. Run the script:
python saludo.py
python3 saludo.py

You should see the greeting message on screen. You just ran your first Python program with AI!

If you see an error, don’t close it: copy the full message and paste it into Claude or ChatGPT. Ask: “I get this error running my Python script, what’s wrong?”. You’ll learn more from the error than from perfect code.

Depurar errores con IADebug errors with AI

Encontrar errores es normal, incluso para programadores con años de experiencia. Con IA, depurar es mucho más rápido:

  1. Cuando un script falla, la terminal muestra un mensaje de error (empieza con Traceback o Error:).
  2. Copia todo ese mensaje.
  3. Abre Claude o ChatGPT y escríbele: “Tengo este error al ejecutar mi script de Python: [pega el error aquí]. ¿Qué está mal y cómo lo corrijo?”
  4. La IA te explica la causa y te da el código corregido.

También puedes compartir todo el script junto con el error para que la IA tenga más contexto: “Este es mi código: [código]. Obtengo este error: [error]. Ayúdame a corregirlo.”

Para ver más técnicas de depuración con IA, visita el tutorial Cómo depurar errores de código con IA.

Finding errors is normal, even for programmers with years of experience. With AI, debugging is much faster:

  1. When a script fails, the terminal shows an error message (starts with Traceback or Error:).
  2. Copy the entire message.
  3. Open Claude or ChatGPT and write: “I get this error running my Python script: [paste error here]. What’s wrong and how do I fix it?”
  4. The AI explains the cause and gives you the corrected code.

You can also share the full script with the error so the AI has more context: “Here’s my code: [code]. I get this error: [error]. Help me fix it.”

For more AI debugging techniques, see the tutorial How to debug code errors with AI.

Proyectos que puedes construir con Python e IAProjects you can build with Python and AI

Una vez que tienes Python y una herramienta de IA, las posibilidades son enormes. Empieza con algo pequeño y auméntalo:

  • Calculadora personalizada: un script que suma, resta y multiplica con menús en la terminal.
  • Organizador de archivos: mueve archivos de una carpeta a otras según su tipo (fotos, documentos, videos).
  • Lector de CSV: lee una hoja de cálculo y muestra los datos ordenados.
  • Contador de palabras: analiza un texto y dice cuántas veces aparece cada palabra.
  • Bot de recordatorios: muestra un mensaje en pantalla al ejecutarse, ideal para automatizar con el programador de tareas.

Para proyectos más grandes, como aplicaciones con interfaz gráfica o con base de datos, visita el tutorial Cómo crear una aplicación con inteligencia artificial (sin programar).

Once you have Python and an AI tool, the possibilities are enormous. Start small and grow:

  • Custom calculator: a script that adds, subtracts, and multiplies with terminal menus.
  • File organizer: moves files from one folder to others based on type (photos, documents, videos).
  • CSV reader: reads a spreadsheet and shows sorted data.
  • Word counter: analyzes a text and shows how often each word appears.
  • Reminder bot: shows a message on screen when run, ideal to automate with the task scheduler.

For larger projects, like apps with a graphical interface or a database, see the tutorial How to create an app with artificial intelligence (no coding).

Si algo sale malIf something goes wrong
ProblemaSolución
python no se reconoce como comandoEn Windows, reinstala Python y marca “Add Python to PATH”; en Mac usa python3 en vez de python
El script no hace nada al ejecutarloRevisa que el nombre del archivo termine en .py y que estás en la carpeta correcta
La IA me da código que no funcionaCopia el error y mándalo de vuelta: “Esto no funcionó, aquí el error: [error]“
Copilot no sugiere códigoRevisa que la extensión esté activa y hayas iniciado sesión con tu cuenta de GitHub
No sé cómo ir a la carpeta correcta en la terminalPídele a la IA: “¿Cómo navego con la terminal hasta mi Escritorio en Windows/Mac?”
ProblemFix
python is not recognized as a commandOn Windows, reinstall Python and check “Add Python to PATH”; on Mac use python3 instead of python
The script does nothing when runCheck that the filename ends in .py and that you’re in the right folder
The AI gives me code that doesn’t workCopy the error and send it back: “This didn’t work, here’s the error: [error]“
Copilot won’t suggest codeCheck that the extension is active and you’re signed in with your GitHub account
I don’t know how to navigate to the right folder in the terminalAsk the AI: “How do I navigate with the terminal to my Desktop on Windows/Mac?”

Preguntas frecuentesFrequently asked questions

¿Se puede programar en Python con IA gratis?Can you program in Python with AI for free?

Sí. GitHub Copilot tiene un plan gratuito con 2.000 completions y 50 chats al mes, y Claude.ai ofrece acceso limitado sin costo. Son suficientes para aprender Python desde cero.

Yes. GitHub Copilot has a free plan with 2,000 completions and 50 chats per month, and claude.ai offers limited free access. Both are enough to learn Python from scratch.

¿Necesito saber programar para empezar?Do I need to know how to code to get started?

No. La IA escribe el código por ti, lo explica línea por línea y corrige los errores. Puedes empezar sin ninguna experiencia previa.

No. AI writes the code for you, explains it line by line, and fixes errors. You can start with zero prior experience.

¿Qué herramienta es mejor para programar Python con IA: Claude o GitHub Copilot?Which tool is better for programming Python with AI: Claude or GitHub Copilot?

Depende del uso. Copilot es ideal para autocompletado dentro del editor mientras escribes. Claude es mejor para proyectos completos, explicaciones detalladas y aprender desde cero. Muchos usan las dos.

It depends on the use. Copilot is ideal for in-editor autocomplete as you type. Claude is better for complete projects, detailed explanations, and learning from scratch. Many people use both.

¿En cuánto tiempo aprendo a programar en Python con IA?How long does it take to learn Python programming with AI?

Con IA puedes escribir scripts útiles desde el primer día. Para tener bases sólidas, entre 4 y 8 semanas con práctica diaria de 30 minutos.

With AI you can write useful scripts from day one. For solid foundations, 4 to 8 weeks with 30 minutes of daily practice.

¿Python necesita instalación?Does Python need to be installed?

Sí, Python debe estar instalado en tu computadora para ejecutar el código localmente. La instalación es gratuita y tarda menos de 5 minutos.

Yes, Python must be installed on your computer to run code locally. Installation is free and takes under 5 minutes.