[output] | function printNumbers (n) { for (let i = 1; i <= n; i++) { console.log(i); } } [instruction] | Design a function in JavaScript to print all natural numbers between 1 to n. [input] |
[output] | <html> <head> </head> <body> <h1>Hello World!</h1> <p>This is a simple HTML page.</p> </body> </html> [instruction] | Generate a valid HTML page given the body contents. [input] | <h1>Hello World!</h1> <p>This is a simple HTML page.</p>
[output] | <User id="47" /> [instruction] | Generate a valid XML tag to represent the following: [input] | Name: User; Attribute: id; Attribute Value: 47
[output] | Blender is a free and open source 3D modelling software which can be used to create 3D designs. [instruction] | Suggest a 3D modelling software for creating 3D designs. [input] |
[output] | SELECT name, grade FROM Students; This query will return the names and grades of all students from the Students table. For example, it will return "Harry A" and "Selman B" and "Linda A". [instruction] | Summarize a MySQL query that prints out the names and grades of students from a table. [input] | Students (name, grade) Harry, A Selman, B Linda, A
[output] | SELECT AVG(grade) FROM Students; This query will return the average grade of all students from the Students table. [instruction] | How would you modify the query to print the average grade of the students? [input] | SELECT name, grade FROM Students;
[output] | function getLastItem(arr) { return arr[arr.length - 1]; } [instruction] | Create a JavaScript function to get the last item of an array. [input] |
[output] | SELECT COUNT(*) FROM Students WHERE grade = 'A'; This query will return the total number of students with an A grade. [instruction] | Write a query in PostgreSQL to find the total number of students with an A grade. [input] |
[output] | let x = 10; x = x > 0 ? x + 5 : x - 5; [instruction] | Rewrite the following JavaScript snippet to use a ternary statement. [input] | let x = 10; if (x > 0) { x = x + 5; } else { x = x - 5; }
[output] | A Binary Search Tree (BST) can be represented using the dictionary data structure in Python. Each node in the tree will be represented by a dictionary containing the keys: ‘value’, ‘left’, and ‘right’. ‘value’ refers to the numeric or string value of the node, ‘left’ refers to the dictionary represe [instruction] | Suggest a data structure in Python to represent a binary search tree. [input] |
[output] | @app.route('/user', methods=['GET']) def get_user(): user_id = request.args.get('user_id') user = db.execute('SELECT * FROM user WHERE user_id = ?', (user_id,)).fetchone() if user is None: `. abort(404) return jsonify(user) [instruction] | Create a REST API endpoint to retrieve specific user data from the database [input] | A relational database with a user table containing: user_id, email, phone_number
[output] | class Employee{ private: int employeeId; String name; int salary; public: Employee(int employeeId, String name, int salary){ this->employeeId = employeeId; this->name = name; this->salary = salary; } int getEmployeeId(){ return employeeId; [instruction] | Create a C++ class to store data of an employee [input] | Employee Data: employee_id, name, salary
[output] | const http = require('http'); const fs = require('fs'); const port = 3000; const server = http.createServer((req, res) => { if (req.method == 'POST') { let body = ''; req.on('data', chunk => { body += chunk.toString(); }); req.on('end', () => { [instruction] | Create a Node.js server to handle POST requests [input] | None
[output] | <input type="text" value="Welcome" /> [instruction] | Create a text box containing the given text [input] | Textbox Text: Welcome
[output] | Syntax Error. The correct syntax should be "a < 45". [instruction] | Identify the type of error in the below given syntax [input] | a < 45
[output] | { name: "John", age: 32, occupation: "Engineer" } [instruction] | Create a MongoDB document containing the following data [input] | Name: John Age: 32 Occupation: Engineer
[output] | public DateTime GetCurrentTime() { return DateTime.Now; } [instruction] | Create a C# method to get the current system time [input] | None
[output] | public class Employee { private String name; private int age; private double salary; public Employee() { } public Employee(String name, int age, double salary) { this.name = name; this.age = age; this.salary = salary; } public String [instruction] | Create a class Employee in Java which contains the name, age and salary of the employee. [input] |
[output] | SELECT TOP 10 c.id, c.name, SUM(d.amount) as total_purchase FROM customers c INNER JOIN details d ON c.id = d.customer_id GROUP BY c.id, c.name ORDER BY total_purchase DESC; [instruction] | Find the top 10 customers based on total purchase amount from the "customers" data table. [input] |
[output] | <!DOCTYPE html> <html> <head> <title>Welcome</title> <style> h1 { text-align: center; } </style> </head> <body> <h1>Welcome</h1> </body> </html> [instruction] | Create a simple webpage to welcome visitors with a centered heading "Welcome". [input] |
[output] | my_list = ["a", "b", "c", "d"] # Convert the list to a string my_string = ''.join(my_list) print(my_string) # Output: abcd [instruction] | Convert a list to a string. [input] | my_list = ["a", "b", "c", "d"]
[output] | def is_empty(str): ''' This function takes as input a string and evaluates its quantity to true or false. ''' if len(str.strip()) == 0: return True else: return False [instruction] | Create a function that takes as input a string and evaluates its quantity to true or false. [input] |
[output] | import re pattern = r"py$" # Check if a string ends with "py" if re.search(pattern, "test.py"): print("String ends with 'py'.") # Output: String ends with 'py'. [instruction] | Write a regular expression to check if a string ends with "py". [input] |
[output] | import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier # Read data and split into training and test sets data = pd.read_csv("customer_data.csv") X = data.drop("target", axis=1) y = data.target X_train, X_test, [instruction] | Train a machine learning model to predict whether a customer is likely to purchase a product. [input] |
[output] | The program can be compiled with the command "g++ <filename>". The program can be executed with the command "./a.out" (assuming the output file is named "a.out"). [instruction] | Compile and execute this program using the C++ compiler. [input] | #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }
[output] | def multiplyByTwo(arr): multipliedArr = [] for i in arr: multipliedArr.append(i*2) return multipliedArr [instruction] | Write a function that takes an array of integers and returns an array of the same length with each element multiplied by 2. [input] | [1, 2, 3]
[output] | The following regex expression can be used to solve this problem: (?<=.)(?=-.)|(?<!-.) [instruction] | Find a way to solve this particular problem using regex. [input] | Given a string "A-C-E-G-I", create a new string "ACE-GI".
[output] | SELECT AVG(Purchase_Length) as Average_Purchase_Length FROM Purchase; [instruction] | Create a SQL query to find the average length of time for all purchases. [input] | Table structure: Purchase (Customer_ID, Purchase_Date, Purchase_Length)
[output] | Using a dataset with two class labels (e.g., yes/no, 0/1, etc.), a machine learning model can be constructed, for example, by using a Support Vector Machine (SVM) method with a suitable kernel. The inputs to the model would be the features from the dataset and the output would be the predicted class [instruction] | Construct a machine learning model to classify a given dataset into two class labels. [input] | Dataset
[output] | The following steps can be taken to create a tensorflow model to predict the probability of rain given an input dataset: 1. Preprocess and clean the input data. 2. Split the data into training and testing datasets. 3. Build a neural network model with the input dataset. 4. Compile the model with a [instruction] | Create a tensorflow model to predict the probability of rain given an input dataset. [input] | Weather dataset