ChatRPG - How to learn Python with AI in a funny way
Tags: learning, chatgpt, python, ai
Published: 2023-07-07 19:01:10

As part of my job search, I'm being introduced to a new language: Python.
As the proud owner of a primate brain on the one hand, I'm well aware of the power that [gamification](https://www.hmhco.com/blog/what-is-gamification-in-education#:~:text=Gamification%20in%20education%20means%20that,%2C%20The%20Sims%2C%20and%20tag.), in the context of learning, can have on me.
As a technophile on the other, I couldn't miss the emergence of artificial intelligence tools, notably the conversational AI phenomenon that is ChatGPT, developed by OpenAI.

How can ChatGPT help me discover Python while making the experience as fun as possible?

_You can read the original French version of this [Here](https://mxmtrn.odoo.com/blog/blog-5/chatrpg-une-fantastique-quete-sur-les-terres-sacrees-de-codingoria-2)._

-----------

## FROM ChatGPT - the generalist TO ChatRPG - the Python expert

Although powerful, ChatGPT is even more so when subjected to **role-playing**.
So I've defined how I want ChatGPT to take charge of training me in Python, following a certain formalism to give it as much **context** as possible: 
+ The role of the AI: ChatGPT will be a Python expert with a strong propensity for teaching.
+ What I expect from the AI: ChatGPT will have to introduce me to the most common syntax and methods of the Python language.
+ The method: in order to achieve this, I want ChatGPT to propose a series of exercises, I'll tell it I have a certain amount of knowledge (JS), and I'll ask it to provide me with external documentation so that I can explore the notions that I am learning further (and, moreover,  it will allow me to check that ChatGPT isn't fooling me).
+ The way: finally, I introduce the notion of gamification of my learning, specifying my minimum expectations on this subject: (RPG, Mage, notion of xp).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sb9m9kikj0wlgk79tcbd.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6fp4mziny0h5nvshqy3.jpg)

--------------

## Become a powerful Mage

Initially, ChatGPT provided me with a series of "exercises", even though it's called that, it's nothing more than code extracts enabling me to grasp the basics of Python syntax. As agreed, he provided me with documentation, gave me experience so that I can level up, and listed the skills acquired during this first phase.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enlknwd8fioh2skb2uuj.jpg)

Having reached Level 7, I asked ChatGPT to provide me with a more substantial challenge than simply copying code into my IDE.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1leynl3sf4bz4ezjkslp.jpg)

> Notice how OpenAI doubts my kindness when I ask ChatGPT to kick some ugly monsters in the teeth.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05extyc8j5ly4ymmkn88.jpg)

After having been congratulated on my perspicacity facing this first boss, which I easily swept aside, and then provided with a new code-copying "exercise", I had to face my **first real challenges**.

------------

## OMG The Data Dragon!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uvq5k0zjjs7ow95p69t.jpg)

Unimpressed by the enemy, and helped by a good [documentation](https://realpython.com/python-csv/), I naturally **slaughtered the hot breathed creature**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc99ytb9ua1xommvf04r.jpg)

This is where learning via conversational AI makes sense. ChatGPT is capable of providing an **alternative solution** while **explaining the difference** between the two proposals. We'll see a little later that it's capable of being even more complete when it comes to analyzing the code I propose.

The other advantage is the ease with which you can "shape" the conversation. This way, I was able to obtain an Artifact, and that's [dopamine directly in the veins](https://gamequitters.com/how-dopamine-impacts-gaming/).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3gn9v4ildd4qg4xak9ow.jpg)

> Yeah I claimed, so what?!?

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwgip77bxvndca9egxlq.jpg)

> A bit of Lore, it's always nice

-------------

## The Pythonic Monster !

After a new series of exercises / lessons, a few questions about instruction 'with', a little challenge on how to throw exceptions, some article reading, and a lot of level up; I asked to take on a **new monster**.
ChatGPT offered me a multi-stage challenge (a succession of small algorithmic problems), with the promise of a chest full of well deserved loot :

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x4smezu8x4p5gt8e3ns.jpg)

Once again ChatGPT provides a **quality correction**, and is complete enough to demonstrate the advantages of its solution over mine.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdib3o0ek166zo6t1e9b.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ew8lq6h75o62xmq0xnoa.jpg)

> What's more, I got a really cool amulet!

----------------

## Make ChatRPG even more RPGed with an MCQ

At this stage of my discovery of Python with ChatGPT, I thought it would be a good idea to check that I'd acquired the concepts I'd seen previously.
So I asked the AI to generate a MCQ for me, which I included in an encounter with an NPC (non-player character), with the promise of being rewarded with a [familiar](https://static.ankama.com/dofus/www/game/items/200/18035.png) if I succeeded.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm9d0t43epo7swxb6m4h.jpg)

So, after answering the questions of a **strange but clever peasant** (probably Gandalf undercover), I was able to choose a companion for the rest of my adventure.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmyhoirc0o4bqocarl00.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mj4wiamzm3u50ap0t73g.jpg)

Aware that I sometimes find it difficult to **factor** and **optimize** my code, I've chosen to fight my next battles alongside the Shadowstalker.
The beast has a whole arsenal of techniques that will enable me to be more efficient in the future.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m1m1hdqhgydarfx5dca5.jpg)

ChatGPT lets me apply a different reading to my code **according to the needs** I've identified beforehand! So I can ask for specific feedback without having to define what kind of feedback I need.
Here, for example, is the first of the techniques applied to a problem I was given on a quest further along my initiatory journey: the aim of the problem was to generate all the prime numbers up to the number entered by the user.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydrrbpwrygruirdb9x9g.jpg)
> It's got style!

--------------

## Conclusion 

Considering what I already knew about ChatGPT, the AI has lived up to my expectations regarding its ability to support the discovery of a new programming language.
I was, however, very enthusiastic about its ability to bring a gamification layer to the process.
Here, in no particular order, is a list of the pros and cons I encountered during my experience: 

1. Pros: 
- Quick and easy to set up.
- Adaptable over time.
- Satisfactory progress overview.
- Lore is ok.
- Ability to correct behavior that doesn't meet your expectations.
- Possibility of re-launching the latest ChatGPT contribution if it doesn't suit you.
- "Wow, it can do that ?!" effect. 

2. Cons
- Commits a few errors and inaccuracies: for example, the first version of the MCQ included a question to which no answer could be given.
- Requires reminders from time to time: "don't forget to provide me with documentation", "give out rewards for success", "you must include my progress in the general Lore of our conversation", etc.

A few tips if you want to try out this way of learning: 
- Don't use this method on a subject you don't know too much about! If ChatGPT makes a mistake or lies to you, you won't know.
- Give him as clear and precise information as possible.
- Don't give it too many instructions at once. At the end of my experiment, I tried to automate the way it generates learning and challenge phases, in a prompt of around thirty lines and with sometimes complex instructions. The result? I broke everything!
- Nothing beats the expertise of a human being! Pedagogy is a virtue that's reserved for us, the machine is currently unable to appreciate precisely what a student needs to get the most out of what he/she 's learning. If you want to be trained in the best possible conditions, call a professional.

-------------

## Bonus

I asked ChatGPT to provide me with prompts to generate images using [Stable Diffusion](https://en.wikipedia.org/wiki/Stable_Diffusion). 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm3d5ie10ecmjx3vedav.jpg)

ChatGPT :

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvg2pio8h6vv7hcqj93k.jpg)
> He's not wrong. What about [copyright management for artists present in datasets used to train models](https://theconversation.com/generative-ai-is-a-minefield-for-copyright-law-207473) ? Vast subject.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1atm7x86yrjlxm6kutg1.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vyj32c480gnlxuniub0k.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4x9aqzm71w0dp3n636x.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tp2yn78aombulixszc31.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j33zm1bz5et1lyzg6qz1.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8m9dc5ark43fmeh2xqyw.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ooloep64mh7nu4cwy3db.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tl90uvo4pp1dav3y2fz.png)

Thanks !