Using AI to Write a Python Script

Everyone’s doing it! AI tools have been around for quite a while, but they are definitely having a moment, and people are enjoying the thrill of discovery with these new tools.

I thought it would be fun to show a quick and easy way you can use Google Gemini to create a simple Python app that tells you the weather.

Google Gemini Page

Enter this:

Create a Python script that connects to the National Weather Service API and gives the next week’s forecast for a specified location.

Result

Note: The results might be slightly different each time you ask Gemini the same prompt. The first time I ran it, Gemini provided the latitude and longitude coordinates for New York City. The next time, the coordinates were for San Francisco.

Gemini Response

To improve the line breaks, I displayed the script in Visual Studio Code and put my email address in the HEADERS section:

Python Script in VS Code

Final Details

Additional Details

Of course you also have to know how to install requests and run the Python script on your computer! But Gemini did the coding for you. Sweet!