You are on page 1of 31

ChatGPT for Coders

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Agenda
In this session, we will discuss:
● Introduction to AI and ChatGPT
● ChatGPT v/s GitHub Copilot
● Using ChatGPT with and without Programming Expertise
● ChatGPT to build programs
● Code Interpreter(Beta) in ChatGPT
● Interpreting Code using ChatGPT
● Debugging with ChatGPT
● Exception Handling using ChatGPT
● Testing using ChatGPT
● Extra uses of ChatGPT
● Coding Limitations of ChatGPT
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Introduction to ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
What is Artificial Intelligence?
● Artificial Intelligence is the simulation of human intelligence in machines designed to
think and act like people.

● AI involves the development of algorithms and computer programs that can perform
tasks that typically require human intelligence, such as understanding natural
language, recognizing objects and images, making decisions, and solving problems.

● Example: Virtual personal assistants, such as Apple’s Siri or Amazon’s Alexa.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
What is ChatGPT?
● ChatGPT is an AI-powered language model developed by OpenAI.

● OpenAI is a non-profit AI research organization founded with the goal of


promoting and developing friendly AI in a way that benefits humanity as a
whole.
● ChatGPT is based on the GPT (Generative Pre-trained Transformer)
architecture and has been trained on a large corpus of text data to generate
human-like text in response to prompts.
● ChatGPT 3.5 is available for free public use. But ChatGPT 4 is monetized
considering to be the premium version.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
ChatGPT v/s GitHub Copilot

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
ChatGPT v/s GitHub Copilot
ChatGPT GitHub Copilot

For those just starting out or learning Professional developers are advised
to code, ChatGPT is a suggested to use the premium GitHub Copilot.
general solution because it is free and
can help generate code with
explanations.

ChatGPT can help develop code and Machine learning is used by GitHub
follow up on it, but if the conversation Copilot to continuously learn from
is lost, it cannot continue without code and behaviour, enhancing
special instruction. suggestions over time.

ChatGPT 3.5 is totally free to use, Although it provides a 60-day trial


making it a fantastic option for users period, GitHub Copilot requires a
just getting started. paid subscription.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Using ChatGPT with and without
Programming Expertise

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Using ChatGPT with and without Programming Expertise
With Programming Expertise:

● We can incorporate ChatGPT with our own programmes or services by using the
OpenAI API. Because of this, we may create intelligent chatbots, automated customer
service systems, and other language-based solutions that are customised for your
requirements.
● With programming knowledge, the underlying ChatGPT model can be improved to be
more domain-specific on particular datasets.
● ChatGPT can be used to help with producing code snippets, creating documentation,
or come up with programming problem-solving ideas.
● We may influence ChatGPT's behaviour and make sure it complies with our
requirements by being aware of the underlying architecture and APIs.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Using ChatGPT with and without Programming Expertise
Without Programming Expertise:

● We can communicate with ChatGPT normally with day to day words which we use. We
can converse informally, ask questions, get writing tips, obtain creative writing
recommendations, and discuss ideas.
● Although ChatGPT is a strong language model that can provide responses that
resemble those as of people, it might not be able to comprehend sophisticated
programming-related questions or offer in-depth programming assistance.
● We won't be able to expand ChatGPT's functionality or adapt it to particular
programming requirements without programming knowledge.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
ChatGPT to build programs

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
ChatGPT to build programs
Task 1: Program to build BMI Calculator
Prompt:
Write a program in Python to calculate BMI

Task 2: Program to display powers of 2 using anonymous function


Prompt:
Write a program to display powers of 2 using anonymous function

Task 3: Program to check if two Strings are Anagram.


Prompt:
Write a program to check if two Strings are Anagram.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Code Interpreter in ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Code Interpreter (Beta) in ChatGPT
● The most recent addition to OpenAI ChatGPT (particularly with the GPT-4 model) is
the Code Interpreter, which enables us to execute Python code in a real-time
working environment.
● It essentially functions as a sandboxed Python environment where any Python code
can be run to do any purpose.
● It may seem like a function designed for programmers, but it may assist regular users
with a variety of tasks as well.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Interpreting Code using ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Interpreting Code using ChatGPT
Comparison between ChatGPT 3.5 and 4.0

ChatGPT 3.5 ChatGPT 4.0

ChatGPT 3.5 is “unimodal” - the ChatGPT 4 can now understand and


chatbot only understands and process even images, and it accepts
interprets text input. both text and image prompts. Hence
it is “multimodal”.

ChatGPT 3.5 was failing to understand ChatGPT 4 can produce improved


the subtle nuances when it came to poems or essays with much better
natural human language. coherence and creativity.

ChatGPT 3.5 has no code interpreter ChatGPT 4.0 has code interpreter
option. (beta) feature.

ChatGPT 3.5 does not allow file upload ChatGPT 4.0 lets user upload code file
or output download. and download the output.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Interpreting Code using ChatGPT 3.5
Task 1 : Program to add two numbers

Prompt:
Write a program to add two numbers
Task 2 : Modify the existing code file adding extra code features
Prompt:
Add other arithmetic operations for the existing code

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Interpreting Code using ChatGPT 4.0
Open → Settings → Beta → Code Interpreter → Switch on the toggle

Task 1 : How to upload code file ?


Task 2 : Modify the existing code file adding extra code features
Task 3 : Download the modified code file

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Debugging with ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Debugging with ChatGPT
Task 1: Paste/Type below code on ChatGPT interface and find the error

Prompt 1:
Debug the program and provide corrected code

Prompt 2:
Is there any other method which can be used in coding the same problem statement

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Debugging with ChatGPT
Task 1: Paste /Type below code on ChatGPT interface and find the error

Prompt 1:
Debug the program and provide corrected code
Prompt 2:
Is there any other method which can be used in coding the same problem statement
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Exception Handling using ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Exception Handling using ChatGPT
Task 1: Paste /Type below code on ChatGPT interface and find the type of error

Prompt 1:
Add an exception for the above code
Prompt 2:
Add an exception to handle decimal index value

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Exception Handling using ChatGPT
Task 2: Paste /Type below code on ChatGPT interface and find the type of error

Prompt 1:
Add an exception for the above code
Prompt 2:
Add an exception with another logic

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Testing using ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Testing using ChatGPT
Prompt 1:
Write unit test for above code
Prompt 2:
Suggest code improvement ideas for the above code
Prompt 3:
Implement any one of the idea and provide the code

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Extra uses of ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Extra uses of ChatGPT
Prompt 1:
Provide code documentation for the above code
Prompt 2:
Suggest code improvement ideas for the above code
Prompt 3:
Implement any one of the idea and provide the code
Prompt 4:
Create a dummy spreadsheet with four columns (Name, Age, Income, City) and fill
it with 10 rows of dummy data. Format the resulting spreadsheet data as a table.
Check in GPT 3.5 and 4

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Coding Limitations of ChatGPT

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Coding Limitations of ChatGPT
ChatGPT has some limitations due to its underlying architecture and training data.
Here are some of the key limitations of ChatGPT 3.5:

● Lack of Context Beyond 2048 Tokens


● Generating Incorrect Responses at some instance
● Sensitive Content and Bias
● Verbosity and Repetition
● Lack of Clarification for Ambiguous Queries
● Non-Contextual Responses
● Domain Expertise and Specific Knowledge
● Generating Creative or Fictional Content
● Not a Replacement for Professional Advice
● Unpredictable Outputs

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Summary
A quick recap:

● ChatGPT is a type of language model that uses deep learning to generate human-like responses to
text-based prompts.
● ChatGPT and GitHub copilot had many differences with respect to premium access, response to the
prompts, trained data set etc.
● Programmers and non programmers can easily work with ChatGPT, but its an added advantage when a
end user is well knowledged on programming.
● Many prompts and examples on codes were demonstrated on aspect of how to buid programs, debug,
handle exceptions, code testing.
● Demonstrated extra uses of ChatGPT like code documentation and dummy data creation.
● ChatGPT has some limitations due to its underlying architecture and training data listing few like
verbosity repetition, sensitive content bias etc.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited

You might also like