# Learn coding with AI

## Music Intro

π Let’s dive into the world of AI together, shall we?

Ever wondered how to bring your coding dreams to life without getting stuck in the weeds? Look no further! Let’s use a magical tool called ChatGPT 3.5 by OpenAI. It’s like having a super-smart teacher, who speaks all the coding languages and loves to help you out.

I can tinker with Python, JavaScript, Groovy, C#, and more, but who has time to write examples in every language. On the other hand: With ChatGPT, we can simplify things and I can let you use ChatGPT to translate the code from one language to another!

How cool is that?

So, if I take the following code:

Python
``````# Given
number1 = 1
number2 = 2

# When
result = number1 + number2

# Then
print(result)``````

and put it into ChatGPT as:

``````Can you please translate the following Python script into JavaScript:
--
# Given
number1 = 1
number2 = 2

# When
result = number1 + number2

# Then
print(result)
--``````

Then the result will be in ChatGPT:

We can translate it into Groovy, C# or any other language!

## Finding a bug

Picture this: We’re deep in the jungle of code, hacking away like fearless explorers. But uh-oh, something’s amiss! Our code isn’t playing nice. Cue the dramatic music π΅

But fear not, dear friends! With ChatGPT by our side, we can unravel the mystery of the pesky bug. Take this scenario, for example: We accidentally sprinkle a bit of JavaScript magic (hello, ‘const’!) into our Python potion. Oopsie daisy!

Lets try it our self with: π» Python / π» JavaScript π» Groovy / π» C#

Python
``````# Given
const number1 = 1
const number2 = 2

# When
const result = number1 + number2

# Then
print(result)``````

It will give the following error message:

Which seems quite cryptic to begin with, but becomes easier to understand over time.

ChatGPT can help with us here:

``````I have the following python code:
--
# Given
const number1 = 1
const number2 = 2

# When
const result = number1 + number2

# Then
print(result)
--

That gives me the following error:
--
err

File "apps/console-python/", line 2
const number1 = 1
^^^^^^^
SyntaxError: invalid syntax
--

Can you help me understand what is wrong?``````

And ChatGPT gives a excellent answer:

## Can’t ChatGPT just translate from popular language into a programming language?

Yes, it can, except it will quickly get messy quite fast, with a popular language.
Try to write it down and see, that it is not easy to describe.

The description here is quite simple, so ChatGPT will probably guess what you are asking about, but there might be some differences. When more complex system behavior needs to be explained, it can become very difficult.

To get a better result, we could apply a testing language called Gherkin. The language was invented to describe business processes, so an IT-system could behave in a similar way.

``````Can you please translate the following text into Python?
--
# Given there are two variables named numbers with values: 1 and 2
# When they are added together into a result variable
# Then the result variable must be printed.
--``````

Which gave me a very good result:

We can also do it the other way around, to let ChatGPT write our Given, When, and Then:

``````I have the following python code, and I would like you to add Given, When, Then comments into it, so they explain the code:
--
number1 = 1
number2 = 2
result = number1 + number2
print(result)
--``````

With the following result:

Which means we can make ChatGPT explain a piece of code for us as a process in Gherkin, which is close to popular language.

## Conclusion

It’s like having a super helper who makes coding, fixing mistakes (yep, finding and fixing those sneaky bugs), and even translating languages super-duper easy.

This awesome AI buddy is like a superhero for translate code between different languages like Python, JavaScript, Groovy, and C#.

But ChatGPT isn’t just for tech wizards β it’s like having a teacher who can explain all the nerdy stuff in a way that even non-techies can understand! It’s like having a buddy who’s always there to lend a helping hand.

Of course, ChatGPT isn’t perfect. Sometimes, when things get super tricky, it might lead us down the wrong path. But hey, that’s just like when we’re learning new stuff ourselves! We gotta try, mess up, learn from it, and then try again.

As we keep learning and getting better at coding, ChatGPT gets smarter too. It’s like we’re all growing together β making coding easier and more fun for everyone!

So, with ChatGPT by our side, programming becomes not just easier, but also more inclusive and awesome for all of us. How cool is that?

And the best part is: We learn to communicate more precise with the machines, when they will build our future hospitals, schools, and other important institutions!

### Important:

So, here’s the plan for the future:
I’ll lay down my examples using just one language, and then you can work your magic and translate it into whatever language floats your boat!

And hey, if you drop it in the comments, you’ll be a superhero for helping out others too! How awesome is that? Let’s spread the coding love together! ππ

### Congratulations – Lesson complete!

You can comment below or on here: