Google AI Is Teaching Me Python

And it’s actually fun

Christopher Kokoski
The Generator

--

Robot learning Python in an office — Google AI Is Teaching Me Python
I made this image but not the content using ChatGPT and DALL-E — Credit

I love experimenting with new tools — and AI tools are insanely addictive, especially when they can teach me new ideas, concepts, and skillsets.

My latest experiment (aka “Playground Learning”) is to learn basic Python.

And I mean very basic.

While ChatGPT is still top AI dog in my opinion, I also really like Gemini AI. So, to learn a little Python, I turned to Gemini.

The results were (to me) impressive.

Here’s What Happened First

The exact first springboard to my learning was prompting Gemini AI to teach me a beginner lesson about Python.

Here is the exact prompt I used:

I want to learn Python code. I am a complete beginner who barely knows anything about HTML. Please teach me a first lesson of learning python code as if I am a young child. I want a beginner’s first lesson where I can actually learn something. Focus the lesson on practical learning that is quickly usable.

As it turns out, this prompt worked like magic.

Gemini quickly (in seconds) churned out a simple lesson using simple language that made sense to my untrained, non-Python brain.

Not only did I get an easy explanation of Python scripting, Gemini also taught me a very easy code that I could instantly apply and see results. It’s below ground-level basic stuff but that’s what I needed.

Gemini also allowed to do test some of the code right there in the AI tool.

I thought that was pretty awesome.

Not only that but Gemini AI also made the lesson short and sweet, suggesting how I might practice before the next lesson.

For anyone curious, I’m going to post as much of the first lesson as I can in the very next section.

My First Python Lesson With Gemini AI

Without further ado, let me share with you the lesson that Gemini AI generated for me (Everything below this sentence, in this section, is from Gemini AI):

Absolutely! Let’s think of Python as a special language you can use to talk to your computer and give it instructions. Here’s our first lesson:

Lesson 1: Talking to Your Computer

Imagine a Magic Box: Pretend your computer is a magic box that understands your special Python language.

Saying “Hello World!”: One of the first things we often teach computers to say is “Hello World!”. Here’s how to do it in Python:

print("Hello World!")

Understanding the Code: Let’s break down what this means:

print(): This is a special word (like a magic spell!) that tells the computer "show this on the screen".

"Hello World!": This is the message you want the computer to show. The quotation marks tell the computer this is text and not more code.

How to make it happen:

Find the magic typing place:

Online: There are websites like Repl.it (https://repl.it/languages/python3) where you can type code and see it work instantly.

On your computer: Your computer might have a program for writing Python. Look for something like “IDLE” or “Python”.

Carefully type in the code:

print("Hello World!")

Find the “Run” button: It usually looks like a play button (a triangle pointing to the side). Click it!

What should happen: You’ll see the words “Hello World!” appear on your screen. Congratulations, you just wrote your first Python program!

Let’s try something more:

Changing the message: What if you want to say something different? Try changing the text inside the quotation marks:

print("My name is [Your Name]!")

Important things to remember:

Computers are picky: They like things spelled exactly right. Check your typing carefully!

Practice makes perfect: The more you try these little code spells, the better you’ll become at speaking Python.

Let me know if you’re ready for Lesson 2!

Here’s How It Actually Went

I tried running the code directly in Gemini AI (the AI tool provided code boxes — that’s what I’ll call them, anyway). This worked for some of the Python code but not for most of it.

Therefore, I turned to Google Collab.

It’s free, pretty intiuitive to use, and worked like a charm. After a short learning curve, I figured out how to test the practice code from Gemini AI.

After this first lesson, Gemini AI generated four or five more beginner level lessons, all with simple information and practical exercises for hands-on learning.

For example:

  • In lesson 2, I learned how to do math with Python (make a simple calculator code)
  • In lesson 3, I learned how to have a conversation with Inputs. In a very rudimentary way, I built a baby chatbot that asked me for information and then responded based on my answer.
  • In lesson 4, Gemini taught me how to write a simple story by feeding Python a character name, a place, and an object. It was Mad Libs style Python coding and pretty fun.

Here’s an example of some of the code from lesson 4:

print("Once upon a time, there was a brave adventurer named", character_name)
print("They traveled to the mysterious land of", place)
print("There, they discovered a", object, ". The end!")

What was cool is that, when I asked for another lesson after lesson 4, Gemini instead generated a recap of the first four lessons with a summary, review information, practice exercises, and tips.

In the next few lessons, I learned about decisions, variables, and what I could do with “if, elif, and else.”

When I told Gemini that I am interested in Python use-cases for blogging, the AI went into a lesson about building an automatic title case generator. I was able to follow along and build a simple script in a few minutes.

I thought it was super cool and it felt great to make something that I would actually use in the real world.

Final Thoughts on Playground Learning With AI

I should mention that I was using the Pro/paid version of Gemini for this experiment. I signed up just to see what it could do.

I still prefer the capabilities and features of ChatGPT but I really like the interface of Gemini. I also tried Claude Opus and was not very impressed for my use cases.

I’m sure it’s great but I’ll stick with ChatGPT for now.

With all that said, I think you can get similar results for learning Python (or anything else) from any of the advanced AI models.

Thanks for reading!

Join the Generator’s Newsletter: https://medium.com/the-generator/newsletters/ai-in-real-life-the-generator-newsletter

--

--

Christopher Kokoski
The Generator

Endlessly curious| proud word nerd| Don’t miss my next article — sign up to my Medium email list: https://bit.ly/3yy18Bc