Chatgpt Developer Cheatsheet
Chatgpt Developer Cheatsheet
io/blog/chatgpt-cheat-sheet-for-developer
Login
1 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
3 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
5 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
6 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
7 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
10 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
def sum_list(nums):
import java.util.*;
11 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
import java.util.*;
import java.util.*;
public class evenodd {
public static void main(String[] ar
gs) throws InterruptedException {
Scanner sc = new Scanner(Syste
m.in);
System.out.print("Enter the low
er range: ");
int lower = sc.nextInt();
System.out.print("Enter the upp
er range: ");
int upper = sc.nextInt();
evenThread.start();
oddThread.start();
evenThread.join();
12 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
evenThread.join();
oddThread.join();
System.out.println("Sum of even
numbers: " + evenSum);
System.out.println("Sum of odd
numbers: " + oddSum);
}
}
13 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
function calculateSum(nums) {
let sum = 0;
for (let i = 1; i < nums.length; i++)
{
if (nums[i] % 2 == 0) {
sum += nums[i];
}
else {
sum -= nums[i];
}
}
return sum;
}
14 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
def find_max(lst):
max_value = lst[0]
for i in range(1, len(lst)):
if lst[i] > max_value:
max_value = lst[i]
return max_value
15 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
ber;
this.balance = balance;
}
public BankTransaction(BankAccount
account1, BankAccount account2) {
this.account1 = account1;
this.account2 = account2;
}
Account(123, 1000.0);
BankAccount account2 = new Bank
Account(456, 2000.0);
BankTransaction transaction1 =
new BankTransaction(account1, account
2);
BankTransaction transaction2 =
new BankTransaction(account2, account
1);
t1.start();
t2.start();
}
}
18 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE use
rname = '$username' AND password = '$pa
ssword'";
$result = mysqli_query($conn, $query);
19 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
20 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
21 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
22 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
23 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
24 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
def calculate_mean(numbers):
total = sum(numbers)
mean = total / len(numbers)
return mean
def calculate_median(numbers):
numbers.sort()
25 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
numbers.sort()
if len(numbers) % 2 == 0:
mid = len(numbers) / 2
median = (numbers[mid - 1] + nu
mbers[mid]) / 2
else:
mid = len(numbers) // 2
median = numbers[mid]
return median
numbers = [1, 2, 3, 4, 5]
mean = calculate_mean(numbers)
median = calculate_median(numbers)
print(f"Mean: {mean}")
print(f"Median: {median}")
26 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
public MyDatabase() {
data = new ArrayList<String>();
}
27 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
28 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
public MyDatabase() {
data = new ArrayList<String>();
}
29 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
def calculate_mean(numbers):
total = sum(numbers)
mean = total / len(numbers)
return mean
def calculate_median(numbers):
numbers.sort()
if len(numbers) % 2 == 0:
mid = len(numbers) / 2
median = (numbers[mid - 1] + nu
mbers[mid]) / 2
else:
mid = len(numbers) // 2
median = numbers[mid]
return median
numbers = [1, 2, 3, 4, 5]
mean = calculate_mean(numbers)
median = calculate_median(numbers)
assert mean == 3
assert median == 3
30 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
31 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
32 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
33 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
def calculate_grade(score):
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "F"
34 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
return grade
function sum(n) {
let result = 0;
for (let i = 1; i <= n; i++) {
result += i;
}
return result;
}
console.log(sum(1000000));
35 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
#include <iostream>
#include <fstream>
int main() {
std::string filename = "example.txt";
36 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
if (file) {
std::cout << "File opened successfu
lly." << std::endl;
} else {
std::cout << "Failed to open file."
<< std::endl;
}
file.close();
return 0;
}
37 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
try:
num_list = [float(num) for num in n
um_list]
except ValueError:
print("Error: Invalid input")
exit()
if not num_list:
print("Error: No numbers provided")
exit()
38 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
39 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
40 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
41 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
42 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
43 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
import psycopg2
conn = psycopg2.connect(
host="localhost",
database="mydatabase",
user="myusername",
password="mypassword"
)
cur = conn.cursor()
cur.execute("SELECT * FROM mytable")
rows = cur.fetchall()
conn.close()
44 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
try:
num_list = [float(num) for num in n
um_list]
except ValueError:
print("Error: Invalid input")
exit()
if not num_list:
45 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
47 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
48 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
49 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
50 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
51 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
Explore More
search...
52 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
First name
Email address
Subscribe
In this article
53 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
GitHub
ChatGPTCopilot
Promptsvs
forAmazon CodeWhisperer | Who's
Code Generation
Best in 2024?
ChatGPT Prompts for Code Completion
54 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
Programming
DevOps
Data Science
Design
Articles About us
Roadmaps We Feedback
Privacy Policy
Cookie Policy
Disclosure Policy
Disclaimer
Refund Policy
Follow us
Disclosure: This page may contain affliate links, meaning when you
55 of 56 11/24/24, 19:53
ChatGPT Cheat Sheet for Developers | 40 Best Prompts https://hackr.io/blog/chatgpt-cheat-sheet-for-developer
56 of 56 11/24/24, 19:53