Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Coding in SQL, Python, VBA, JQuery and OfficeScript using AI tools Part three of an eight-part series of blogs |
---|
One of the immediate and obvious ways to use AI tools is to boost your productivity as a programmer. This blog shows how you can use ChatGPT 4 and Google's Bard to write programs in SQL, Python, VBA, JQuery and Office Script (probably the 5 languages Wise Owl use most).
|
The next AI challenge was to get help writing the following Python program:
"Create a Python function which - given a passage of text - will return a dictionary containing all of the unique words"
Again I've been deliberately slightly vague, to see how well the AI tool can guess what I meant. Let's start with ChatGPT 4 again.
Here's ChatGPT 4's answer for my question:
This is an astonishingly good answer, and scares this programmer!
How on earth can this possibly work? Not only has ChatGPT come up with a superb first answer, but it's come up with a second variant in case the first one runs too slowly.
Here's why the first answer is so impressive:
Feature | Notes |
---|---|
Regular expressions | Most humans would (like Bard - see below) have just used a split function to split the input text into different words. Not only has ChatGPT used a more demanding regular expression, but it's also made sure that it accounts for case sensitivity too. |
List comprehension | Again, most human programmers would probably have converted the words to a set to get just the unique ones, then looped over this to get the number of occurrences of each, and then somehow stored the results in a dictionary. ChatGPT has produced a concise list comprehension to do all of this in a single line of code. |
Explanation | ChatGPT has not just included comments within its code, but also added an insightful explanation at the end of how the code works. |
Here's Bard's response to my question:
Python programming in Bard.
As for the previous SQL example this initially looks good, until you realise that the sample answer is wrong (it misses out half the words in the text). On the plus side Bard has included excellent comments, and its function would give a list of the unique words in the text passed in (albeit that it wouldn't do what the question asked, and count the number of occurrences of each word).
ChatGPT is (by a very long way) the winner here: it's hard to imagine firstly how on earth an AI tool can do this, and secondly how much better it could get. Python programmers of the world, be very scared!
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.