ChatGPT and programming

29

October

2023

5/5 (1)

I have heard from friends about the capabilities that ChatGPT has for helping programmers write code. Therefore, in this blogpost, I will test ChatGPT’s coding knowledge and accuracy. To do this, I will ask ChatGPT to create some simple programs from scratch, and test if the code that ChatGPT generates actually works. Usually, one of the first things that you learn when programming is how to program a calculator. Therefore, I will ask ChatGPT to program a calculator in Python as this is a common language and I am planning on learning it during the course of my BIM studies.

The inputs is as follows: Program a calculator in Java and Program a calculator in python.

This is the result:

When I run  the python script it gives me the following result:

As you can see, the calculator works, and I decided to also test the dividing by zero function just to be sure. I find it interesting that ChatGPT is capable of creating this code in a couple of seconds, and also does not forget to include that division by 0 is impossible. Now that we know that this works, we can try to test further and see what the limits are of how much ChatGPT can do without me having to write a single line of code.

Therefore, to improve the calculator, I asked ChatGPT to add buttons so that we do not have to type the operation we have to perform. This was ChatGPT’s output:

When testing the code, we get a working calculator which has buttons.

I find this quite impressive already. Therefore, I want to see now what would happen if I ask it that the inputted numbers should be able to be clicked on in the screen.

As you can see, ChatGPT just created a fully working basic calculator, and it did so in 3 prompts. I opened another ChatGPT window and made one specific prompt which was: Create a calculator with buttons for input and operations in python. This yielded the same result, showing that if you are specific, ChatGPT can be a very powerful tool to help you with programming. All in all, I am impressed that ChatGPT knows how to create a GUI and working calculator with little input.

Please rate this

Leave a Reply

Your email address will not be published. Required fields are marked *