0% found this document useful (0 votes)
132 views

ChatGPT For Coders Prompts

The document discusses using ChatGPT to build programs through various programming tasks and shows how ChatGPT can be used for debugging, exception handling, testing, and documenting code. It includes code snippets and prompts related to building programs to calculate BMI, use anonymous functions to display powers of 2, check for anagrams in strings, debugging code with errors, adding exceptions, writing unit tests, providing documentation, and improving code. It also discusses checking formatted spreadsheet data in earlier and current versions of ChatGPT.

Uploaded by

krishnarajs.krs1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views

ChatGPT For Coders Prompts

The document discusses using ChatGPT to build programs through various programming tasks and shows how ChatGPT can be used for debugging, exception handling, testing, and documenting code. It includes code snippets and prompts related to building programs to calculate BMI, use anonymous functions to display powers of 2, check for anagrams in strings, debugging code with errors, adding exceptions, writing unit tests, providing documentation, and improving code. It also discusses checking formatted spreadsheet data in earlier and current versions of ChatGPT.

Uploaded by

krishnarajs.krs1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Using ChatGPT to build programs

All the tasks has further prompts to improve time and space complexity with various logic

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.

( Display the time complexity for each program showcase the execution efficiency)

Interpreting Code using ChatGPT 4.0

Task 1 : How to upload code file ? Demo file


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

Debugging with ChatGPT


Task 1: Paste /Type below code on ChatGPT interface and find the type of error
Code:
my_list = [10, 20, 30, 40, 50]
index_to_access = int(input("Enter the index you want to access: "))
value = my_list[index_to_access]
print(f"The value at index {} is: {value}")

Prompt 1:
Debug the program and provide corrected code

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Prompt 2:
Is there any other method which can be used in coding the same problem statement

Task 1: Paste /Type below code on ChatGPT interface and find the type of error
Code:
class MyClass:
def my_method(self):
print("Hello, Everyone!")
class MySubclass(MyClass):
def my_method(self):
print("Thankyou!")
obj =
obj.my_method()
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

Exception Handling with ChatGPT


Task 1: Paste /Type below code on ChatGPT interface and find the type of error
Code:
a = [10, 20, 30, 40, 50]
index_accessing = int(input("Enter the index you want to access: "))
value = a[index_accessing]
print(f"The value at index {index_accessing} is: {value}")
Prompt 1:
Add an exception for the above code
Prompt 2:
Add an exception to handle decimal index value

Task 2: Paste /Type below code on ChatGPT interface and find the type of error
Code:
numerator = 10
denominator = 0
result = numerator / denominator # This line will cause a ZeroDivisionError

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
print("Result:", result)

Testing using ChatGPT


Prompt 1:
Write unit test for above code

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

You might also like