ChatGPT Prompts for Writing and Generating Codes:
Sharing a list of the prompts that can help you to use ChatGPT more efficiently.
Replace the words in block to get the desired result, for example, replace the language with a choice of your language, i.e., C#, JavaScript, Python, NodeJS, etc.
| Initial | Prompt | Example | |
|---|---|---|---|
| 1 | Create | Create a code snippet for a specific programming task or function. | Create a code snippet for Checking if a file exists in Python. | 
| 2 | Create | Create a code snippet for a specific algorithm or data structure. | Create a code snippet for Checking for substrings in C# | 
| 3 | Create | Create a function that function descriptioninlanguage. | Create a function that merges two lists into a dictionary in JavaScript. | 
| 4 | Create | Create a languagefunction totask-description. | Create a C# function to swap two numbers. | 
| 5 | Create | Create a languagescript to sort an array ofdata-type. | Create a Python script to sort an array of strings. | 
| 6 | Create | Create a languagefunction that convertsdata-type Aintodata-type B. | Create a Java function that converts an integer array into a string array. | 
| 7 | Create | Create a languagefunction totask-descriptionwith the following inputs:input-variables. | Create a JavaScript function to return the sum of the given array with the following inputs: [17, 18, 15, 19, 14]. | 
| 8 | Create | Create a languageprogram that readsinput-file-type, performsoperations, and then writes the results tooutput-file-typefollowing the format:describe-format. | Create a C# program that reads a string array, performs sorting, and then writes the results to a CSV file. | 
| 9 | Create | Create a languagescript to parsefile-format, extractinformation, and store the data indata-structurewith the following requirements:requirements-list. | Create a Python script to parse the CSV file, extract the first column, and store the data in a string array with the following requirements: skip the header row. | 
| 10 | Create | Could you create a languagefunction totask, which takes ininput-variablesand returnsoutput, under these constraintsconstraints-list? | Could you create a C# function to add two numbers, which takes in 2 integers and returns the sum of given numbers? | 
| 11 | Create | How do I create a class in languagewith these attributes:attributes-list? | How do I create a class in C# with custom attributes? | 
| 12 | Demonstrate | Give me a code snippet demonstrating how to use a specific library or toolinlanguage. | Give me a code snippet demonstrating how to use HealthChecks in .NET Core. | 
| 13 | Develop | Develop a languagescript thatdescribes the functionality. | Develop a Python script that generates a random and strong password. | 
| 14 | Develop | Develop a languagefunction to performtaskusinglibrary or methodologywith the inputs:input-variables. | Develop a C# function to Zip all the files using the DotNet Zip library with the inputs: array of files. | 
| 15 | Develop | Develop a languageprogram to readfile-type, performoperations, and write the results tooutput-format. | Develop a C# program to read CSV files, skip the header row, and write the results to DataTable. | 
| 16 | Generate | Generate a program that reads input-sourceand outputsdesired-outputinlanguage. | Generate a program that reads an integer array and outputs a reversed array in JavaScript. | 
| 17 | Generate | Generate a sample code for specific library or frameworkusage. | Generate a sample code for .NET Core SignalR usage. | 
| 18 | Generate | Generate a sample code for specific task/algorithm. | Generate a sample code for Bubble sorting. | 
| 19 | Generate | Can you generate a languagecode that implementsdata structure or algorithm? | Can you generate a Java code that implements Transpose of a Matrix? | 
| 20 | Generate | Can you generate a code snippet for specific algorithm/data structureinprogramming language/technology/framework? | Can you generate a code snippet for Huffman Encoding in JavaScript? | 
| 21 | Generate | Come up with a code snippet for a specific UI component or feature. | Come up with a code snippet for a Toast component usage in Angular. | 
| 22 | Implement | Implement a languagefunction to handletask. | Implement a C# function to handle exceptions. | 
| 23 | Implement | Implement a languageprogram that readsinputand writesoutput. | Implement a JavaScript program that reads two integer arrays and writes a merged array. | 
| 24 | Implement | Implement a languagescript that readsfile-formatand stores them indatabase. | Implement a Python script that reads CSV files and stores them in SQLLite. | 
| 25 | Implement | Implement a languageAPI that reads theinput-typeand generates aoutput, and then stores it indatabase. | Implement a Python API that reads the character array, and generates a random key using these characters, and then stores it in SQLite DB. | 
| 26 | Implement | Implement a languagealgorithm fortaskthat takesinput-parametersand returns theoutput. | Implement a C++ algorithm for recursion that takes an array and returns the Mean of the given array. | 
| 27 | Implement | Implement a languagealgorithm fortaskusingconstraint. | Implement a C# algorithm for the factorial of a number using recursion. | 
| 28 | Provide | Provide a languagecode to perform file operations likefile-operations-list. | Provide a C# code to perform file operations like Open, Read, Write, and Close. | 
| 29 | Provide | Provide a code snippet for handling specific error or exceptioninlanguage. | Provide a code snippet for handling SQL exceptions in C#. | 
| 30 | Provide | Please provide a code snippet for specific functionalityinlanguage/technology/framework. | Please provide a code snippet for Decimal to Binary Conversion in Java. | 
| 31 | Provide | Can you provide a languagescript to parsefile-format? | Can you provide a Python script to parse CSV files? | 
| 32 | Rewrite | Rewrite this languagecode:[enter your code here] | Rewrite this C# code: [enter your code here] | 
| 33 | Rewrite | Rewrite this languagecode usingspecific feature or method:[enter your code here] | Rewrite this JavaScript code using recursion: [enter your code here] | 
| 34 | Solve | Can you help me code a languagealgorithm to solve theproblemgiven the constraints:constraints-list? | Can you help me code a C# algorithm to solve the memory leakage problem? | 
| 35 | Solve | Come up with a solution that solves problem-descriptioninlanguageand explain how it works. | Come up with a solution that solves the diamond problem in Java and explain how it works. | 
| 36 | Want to Act | I want you to act as a web developer and write HTML and CSS code for a specific type of web page, withspecific features. | I want you to act as a web developer and write HTML and CSS code for an accordion, with drag and drop feature. | 
| 37 | Want to Act | I want you to act as a languageprogrammer and create a program thatdoes something specificusing aspecific library. | I want you to act as a C# programmer and create a program to create a chatbot using Signalr. | 
| 38 | Want to Act | I want you to act as a data scientist and write languagecode toclean, analyze, visualize, or modela dataset ona specific topic. | I want you to act as a data scientist and write R language code to clean, analyze, visualize, or modela dataset ona specific topic. | 
| 39 | Want to Act | I want you to act as a mobile app developer and write languagecode to createa specific featurefor an Android app. | I want you to act as a mobile app developer and write Flutter code to create a notification widget for an Android app. | 
| 40 | Want to Act | I want you to act as a game developer and write languagecode to createa specific game mechanicfor a 2D platformer game. | I want you to act as a game developer and write C# code to create a specific game mechanicfor a 2D platformer game. | 
| 41 | Want to Act | I want you to act as a code generator and provide a language/technology/frameworkcode snippet for aspecific task. | I want you to act as a code generator and provide a .NET Core code snippet for Swagger implementation. | 
| 42 | Want to Act | I want you to act as a languagedeveloper and write a function that takes adata typeas an input and returns theoutput. | I want you to act as a Python developer and write a function that takes a character array as input and returns the concatenated string. | 
| 43 | Want to Act | As a web developer, I need you to generate a numberbynumbergrid of HTML divs with acolorbackground. | As a web developer, I need you to generate a 10 by 10 grid of HTML divs with a Grey background. | 
| 44 | Write | Write a program that program description. | Write a program that merges 2 arrays. | 
| 45 | Write | Write a function in languageto calculate themathematical concept. | Write a function in JavaScript to calculate the random string. | 
| 46 | Write | Write a languageprogram thatperforms taskusinglibrary or algorithm. | Write a C# program that connects to SQL Server using Dapper. | 
| 47 | Write | Write a languagescript that reads fromdata sourceand outputs todata destination. | Write a Python script that reads from CSV and outputs to an HTML table. | 
| 48 | Write | Write a languagescript toperform the operation. | Write a PowerShell script to automate the API version numbering. | 
| 49 | Write | Write a languagescript to connect to a database and performdatabase operation. | Write a Python script to connect to a database and perform CRUD operations. | 
| 50 | Write | Write a languagescript that interacts withdatabaseand performsoperations. | Write a Python script that interacts with the database and performs the Delete operation. | 
| 51 | Write | Write a languagescript to connect todatabaseand executeoperation. | Write a NodeJS script to connect to SQLite and execute CRUD operation. | 
| 52 | Write | Write a languagescript to parsefile-format, extractinformation, and store the data indata structurefollowing these requirements:requirements-list. | Write a NodeJS script to parse CSV, extract data, and store the data in a table following these requirements: Skip the header row. | 
| 53 | Write | Write a languagefunction tocalculate a mathematical conceptusingalgorithm. The function should take these inputs:input-variablesand returndesired-output. | Write a C# function to find the Fibonacci series of n using recursion. The function should take these inputs: input-variablesand returndesired-output. | 
| 54 | Write | Write a languagefunction namedfunction namethat performs atask. | Write a Java function named ToTitleCasethat converts the string into a Title Case. | 
| 55 | Write | Write a languagefunction to find then-th elementin adata structure. | Write a C# function to find the n-th elementin a given array. | 
| 56 | Write | Please write a languagefunction namedfunction nametotask. | Please write a C# function named CalculateFactorial to calculate the factorial. | 
| 57 | Write | Show me how to write a languagefunction that performsspecific task. | Show me how to write a C# function that performs logging into the database. | 
| 58 | Write | Write a languagefunction forspecific algorithm/data structure. | Write a JavaScript function for Array Rotation. | 
| 59 | Write | Write a program task/algorithm | Write a program to Check Whether a Character is a Vowel or Consonant | 
| 60 | Write | Write a program in languagetoperform file operation | Write a program in C# to check if the file exists. | 
NOTE:
Check here to review more prompts that can help the developers in their day-to-day life.
 
 
              
 
    
Top comments (4)
Thank you very much. Here's the series of steps ChatGPT said it takes to convert text into code:
Semantic Comprehension: ChatGPT analyzes the natural language description provided in the prompt and extracts the key concepts, relationships, and structures inherent in the program or system of programs being described. It identifies the entities, actions, attributes, and relationships described in the text and interprets their significance within the context of the program's functionality and architecture.
Ontological Representation: Based on its semantic comprehension of the description, ChatGPT constructs an ontological representation or conceptual model of the program. This model captures the essential elements of the program, including its components, interactions, dependencies, and behaviors. It organizes this information into a structured format that reflects the hierarchical and relational nature of the program's design.
Serialization: Once the ontological representation is constructed, ChatGPT serializes this structured information into a format that can be effectively processed and utilized within its neural network architecture. This serialization process involves encoding the ontological model into a format compatible with the internal representation and processing mechanisms of ChatGPT, enabling it to manipulate and reason about the program's structure and behavior.
Hi! As-is, this is confusing to read. It would be helpful if you could provide an example for each.
@risclover - added examples for each prompt, hope that helps.