[output] | #include<iostream> int main(){ std::cout << "Hello GPT Community!"<< std::endl; return 0; } [instruction] | Write a C++ program that displays the following text. [input] |
[output] | //Pseudocode //Function to obtain the factors of given input function obtainFactors(int num){ //Variable to store the factors List factors = [] //Loop through all number less than the given input for i = 1 to num { //Check if a particular number is a factor of the given input [instruction] | Generate pseudocode for a program that takes in an integer and prints out all the factors of the given integer. [input] | int num = 18
[output] | //Declare a variable to store the count int count = 0 //Loop through the string for i = 0 to (string length) { //Check if the character matches the given one if string[i] == character{ //Increment the count count++ } } //Print out the count print(count) [instruction] | Create an algorithm for counting the occurences of a specific character in a string. [input] | String: "GPT Learning" Character: "t"
[output] | SELECT COUNT(*) FROM Employees; [instruction] | Construct an SQL query to select the total number of employees in the table 'Employees'. [input] |
[output] | # Python program to calculate compound interest def compound_interest(principal, rate, time): # Calculates compound interest CI = principal * (pow((1 + rate / 100), time)) print("Compound interest is", CI) # Driver Code compound_interest(2000, 0.09, 5) [instruction] | Generate a Python code to calculate the compound interest. [input] | Principal = 2000 Rate of Interest = 0.09 Time = 5
[output] | DELETE FROM Employees WHERE salary = 1100; [instruction] | Construct an SQL query to delete all records from the table 'Employees' with a given salary. [input] | Salary = 1100
[output] | public class LeapYear { public static void main(String[] args) { int year = 2020; System.out.println("Leap years up to "+year+" are :"); for (int i = 1; i <= year; i++) { if (i % 4 == 0) { if (i % 100 == 0) { [instruction] | Develop a Java program that prints all the leap years up to a given year. [input] | Year = 2020
[output] | <html> <body> <form> <label for="name">Name:</label> <input type="text" id="name" name="name"> <br> <label for="username">Username:</label> <input type="text" id="username" name="username"> <br> <label for="password">Password:</label> < [instruction] | Construct an HTML form with five input fields: Name, Username, Password, Email, and Phone number. [input] |
[output] | #Function to sort an array using bubble sort def bubbleSort(arr): #Loop through all elements in the array for i in range(len(arr)): #Loop through all elements up to the one larger than the one at the current position for j in range(0, len(arr)-i-1): #Swap elements if necessary [instruction] | Develop an algorithm for bubble sorting. [input] | [5, 2, 1, 8, 0, 9, 4]
[output] | const mysql = require('mysql'); // Connect const database = mysql.createConnection({ host: 'localhost', user: 'admin', password: 'password', database: 'myDatabaseName' }); //Connect database.connect(function(err) { if (err) throw err; }); [instruction] | Write the code to connect a database in Node.JS. [input] | myDatabaseName
[output] | myDictionary["location"] = "NY"; [instruction] | Write the code to add a key-value pair to an existing dictionary in JavaScript. [input] | myDictionary = { "name": "John", "age" : 24 }
[output] | const fruits = ["apple", "banana", "orange"]; [instruction] | Write the JavaScript code to create an array called fruits and add three values to it. [input] |
[output] | #!/bin/bash echo “This is my first script” [instruction] | Create a new Bash script and print "This is my first script" to the terminal. [input] |
[output] | Math.floor(Math.random() * 10) + 1; [instruction] | Write the code to create a random number between 1 and 10 in JavaScript. [input] |
[output] | def printFullName(firstName, lastName): print(firstName + " " + lastName) [instruction] | Write a function that takes two parameters called firstName and lastName and prints them in the format of firstName + lastName. [input] |
[output] | SELECT DISTINCT categories FROM products; [instruction] | Write the SQL query to return a list of unique values from a table called products with a column called categories. [input] |
[output] | # Create a program that creates a dictionary containing only the squares of numbers up to n n = 10 dict_squares = {x: x*x for x in range(1, n+1)} print(dict_squares) # {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100} [instruction] | Create a program that creates a dictionary containing only the squares of numbers up to n [input] | n = 10
[output] | # Format a given number to a specified number of decimal places num = 12.34567 formatted_num = "{:.2f}".format(num) print(formatted_num) # 12.35 [instruction] | Format a given number to a specified number of decimal places [input] | num = 12.34567
[output] | # Print all unique combinations of an array of integers def all_combinations(nums): result = [[]] for num in nums: temp_result = [] for res in result: temp_result.append(res + [num]) result.extend(temp_result) return result print(all_combinations(nums)) # [[1], [2], [3], [1 [instruction] | Print all unique combinations of an array of integers [input] | nums = [1,2,3]
[output] | # Create a function to allocate resources to parties def allocate(data): total = 0 for item in data: total += item[1] allocation = [i[1]/total for i in data] return allocation print(allocate(data)) # [0.5, 0.3, 0.2] [instruction] | Create a function to allocate resources to parties [input] | data = [["Joe",5],["John",3],["Mary",2]]
[output] | # Replace every character in a given string with its corresponding ASCII code def encode_string(string): result = "" for char in string: result += str(ord(char)) return result print(encode_string(string)) # "72 101 108 108 111" [instruction] | Replace every character in a given string with its corresponding ASCII code [input] | string = "Hello"
[output] | # Using a hash table, construct a program to find all of the pairs of an array whose sum is equal to a given target def find_pairs(arr, target): seen = {} pairs = [] for num in arr: if target-num in seen: pairs.append((num, target-num)) seen[num] = True r [instruction] | Using a hash table, construct a program to find all of the pairs of an array whose sum is equal to a given target [input] | arr = [2,7,5,3,1,9] target = 8
[output] | # define CNN model model_cnn = Sequential([ Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)), MaxPool2D(), Flatten(), Dense(100, activation='relu'), Dense(10, activation='softmax') ]) # define RNN model model_lstm = Sequential() model_lstm.add(LSTM(128, input_shape [instruction] | Generate CNN-LSTM model in Keras. [input] |
[output] | SELECT COUNT(*) FROM users WHERE email = 'example@example.com' [instruction] | Write a query in SQL to count the number of users with a given email address. [input] | Table: users Email address: example@example.com
[output] | <?php $url = 'https://www.example.com/message'; $message = 'This is a broadcast message'; // Create a cURL handle $ch = curl_init(); // Set the URL and other options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $message); [instruction] | Create a PHP script to broadcast a message on a given web page. [input] | Input Web Page URL: https://www.example.com/message Message: This is a broadcast message
[output] | git checkout -b <new_branch_name> [instruction] | Create a new branch of the current project on Github. [input] |
[output] | SELECT * FROM customer ORDER BY first_name; [instruction] | Write a SQL query that returns all records from the "customer" table sorted by first name. [input] |
[output] | def convert_currency(amount, from_currency, to_currency): # use a free online currency conversion API like Fixer # to convert an amount from one currency to another response = requests.get(f"http://data.fixer.io/api/convert?access_key=<your_key>&from={from_currency}&to={to_currency}&amou [instruction] | Create a function to convert a given quantiy of money from one currency to another. [input] | amount: 10 from_currency: USD to_currency: GBP
[output] | def repeat(string, repeats): try: for i in range(repeats): print(string) except: print("Error occured") repeat("Hello World!", 5) [instruction] | Edit this code to add a try-except block to catch any errors. [input] | def repeat(string, repeats): for i in range(repeats): print(string) repeat("Hello World!", 5)
[output] | """ API to pull company data from an external source. Parameters: 1. company_id: Unique id of the company 2. fields: List of strings of fields to include in the response Returns: A JSON containing the specified fields from the external source. """ def get_company_data(company_id, fields): # u [instruction] | Design an API to pull company data from an external source. [input] |