PromptBase
Close icon
General
Home
Marketplace
Hire
Create
Login
Sell
Explore
🤖 GPT

Code Comments Generator

Code Comments Generator gpt prompt mini thumbnail
1Heart icon
Favorites
43Eye icon
Views
GPT-3.5-TURBO
TestedTick icon
🌟Simplify your code documentation process with this comment generator. 📈Save time and improve code documentation with this prompt!
...more
$3.99
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
Over 1 month ago

Prompt Details

Model
Chat - GPT-3.5 (gpt-3.5-turbo)
Token size
190 ($0.00040 / call)
Example input
# Python program for implementation of Bubble Sort def bubbleSort(arr): n = len(arr) swapped = False for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j + 1]: swapped = True arr[j], arr[j + 1] = arr[j + 1], arr[j] if not swapped: return arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print("Sorted array is:") for i in range(len(arr)): print("% d" % arr[i], end=" ")
Example output
ChatGPT: I am ready to generate code comments based on the given guidelines. Please provide me with the input code. User: # Python program for implementation of Bubble Sort def bubbleSort(arr): n = len(arr) swapped = False for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j + 1]: swapped = True arr[j], arr[j + 1] = arr[j + 1], arr[j] if not swapped: return arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print("Sorted array is:") for i in range(len(arr)): print("% d" % arr[i], end=" ") ChatGPT: # Python program for implementation of Bubble Sort def bubbleSort(arr): """ Sorts the given array in ascending order using the Bubble Sort algorithm. Args: arr (list): List of unsorted integers. Returns: None. The list is sorted in place. """ n = len(arr) swapped = False for i in range(n-1): for j in range(0, n-i-1): # Compare adjacent elements and swap them if the first element is greater than the second. if arr[j] > arr[j + 1]: swapped = True arr[j], arr[j + 1] = arr[j + 1], arr[j] # If no elements were swapped in the last iteration, the list is sorted. if not swapped: return arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print("Sorted array is:") for i in range(len(arr)): print("% d" % arr[i], end=" ") The bubbleSort function takes an unsorted list of integers and sorts it in ascending order using the Bubble Sort algorithm. The function does not return anything; instead, it modifies the input list in place. The algorithm works by repeatedly swapping adjacent elements if they are in the wrong order, until the list is sorted. The outer loop iterates n-1 times, where n is the length of the list. The inner loop iterates from 0 to n-i-1, where i is the current iteration of the outer loop. This is because the largest i elements will already be sorted at the end of each iteration. If no elements were swapped in the last iteration of the inner loop, the list is sorted and the function returns. Otherwise, the algorithm continues with the next iteration. The input list in this example is [64, 34, 25, 12, 22, 11, 90]. After the bubbleSort function is called, the sorted list is printed to the console.
Browse Marketplace