Python: How close does AI come to generating Python code based on human input?

Post Reply

Will the roles change in the near future to make developer and manager indistinquishable?

You may select 1 option

 
 
View results

hudatolah
Site Admin
Posts: 152
Joined: Thu Apr 04, 2013 8:10 pm
Are You a Headhunter?: Affirmative
Surfer?: Yes

Python: How close does AI come to generating Python code based on human input?

Post by hudatolah » Tue Nov 21, 2023 10:36 am

I wanted to see how close does ChatGPT come to code written by human. I used a short script that assigns a seed value to a letter in alphabet and sums up all letter of the word given in the input. Here is my version of the script.

Code: Select all

print(f"Enter seed number:")
seednum = input()

print(f"Welcome to SUM IT UP and see if you're COMPATIBLE game")
print(f"To exit type stop. \nTo begin type in a word you'd like to have summed up:")

while True:
    letter_to_number = {chr(97 + i): int(seednum) * (i + 1) for i in range(26)}  # 97 is the ASCII code for 'a'

# Function to calculate the sum of assigned values for a word
    def word_to_number(word):
        word = word.lower()  # Convert the word to lowercase for case-insensitivity
        total = sum(letter_to_number.get(letter, 0) for letter in word)
        return total

# Input a word from the user
    input_word = input()
    if input_word == 'stop':
       break
    else:
# Calculate and print the sum of assigned values for the word
       result = word_to_number(input_word)
       print(f"{input_word},{result}")
Comparing with Chat GPT, it only needs a description of what you needed done. My code has couple extra options and seed changing option and includes a "stop" option. Other than that Chat GPT produced a code that was completely usable at the python prompt. The take away is that we're there now to have AI take over codding for us.

Chat GPT written code:

Code: Select all

while True:
    letter_to_number = {chr(97 + i): 7 * (i + 1) for i in range(26)}  # 97 is the ASCII code for 'a'
    
    def word_to_number(word):
        word = word.lower()  # Convert the word to lowercase for case-insensitivity
        total = sum(letter_to_number.get(letter, 0) for letter in word)
        return total
        
    input_word = input("Enter a word: ")

    result = word_to_number(input_word)
    print(f"The sum of assigned values for '{input_word}' is: {result}")
    
The question then is who is more needed? Is it the middle manager or the developer? My personal view on this that the roles will merge into one. The manager still needs to know and understand what needs to happen, but using functional description of the business service, the code can be delivered completely by AI.

NOTE: Script like this can be used to generate datasets in a database and analysis can be run in the results. Here I just created a simple set of data, but the complexity can increase indefinitely.
The Blackholesurfer. My surfboard has teeth.

Post Reply