[output] | For example, using Node.js: Object.keys(process.env).forEach(key => { console.log(`${key}: ${process.env[key]}`); }); [instruction] | Write a script that prints out the current value of environment variables [input] |
[output] | const product = arr.reduce((acc, curr) => acc * curr, 1); [instruction] | Use the reduce function to calculate the product of elements in an array [input] | [1, 2, 3, 4, 5]
[output] | void updateArray (int arr[], int n) { for (int i=0; i<n; i++) arr[i] = arr[i] * 2; } [instruction] | Develop a C++ function to update the contents of an integer array. [input] | The int array contains {1, 2, 3, 4, 5}. Update the array so that it contains {2, 4, 6, 8, 10}.
[output] | BiFunction <Double, Double, Double> bf = (d1, d2) -> (d1*d2)/2; [instruction] | Rewrite the following code segment using Java 1.8's Lambda Expressions. [input] | BiFunction<Double, Double, Double> bf = new BiFunction<Double, Double, Double>() { public Double apply(Double d1, Double d2) { return (d1*d2)/2; } }
[output] | import datetime def get_current_time(): now = datetime.datetime.now() return now.strftime("%Y-%m-%d %H:%M:%S") [instruction] | Generate a web service function in Python to return the current date and time. [input] |
[output] | Azure Cosmos DB is a NoSQL database-as-a-service model that provides a schema-free data model and supports automatic indexing of all data. To model a posts database with CosmosDB, create a database and a container. Then create item in the container, each item should contain the fields "Post ID", " [instruction] | Model a NoSQL database using CosmosDB [input] | The database should store user posts, which consists of the post ID, content text, user ID and date of creation.
[output] | @mixin myshadow($shdwBlur, $shdwColor) { -webkit-box-shadow : 0 0 $shdwBlur $shdwColor; -moz-box-shadow : 0 0 $shdwBlur $shdwColor; box-shadow : 0 0 $shdwBlur $shdwColor; } [instruction] | Write a SASS mixin to add shadow style to multiple elements [input] |
[output] | class Student { constructor(name, age, lastScore) { this.name = name; this.age = age; this.lastScore = lastScore; } } [instruction] | Design a JavaScript class to instantiate objects for student records. [input] | The student records should store the student name, age, and score of the last test.
[output] | var myArray = []; myArray.push('x', 'y', 'z'); [instruction] | Modify the following code segment to add multiple values in an array [input] | var myArray = []; myArray[0] = 'x';
[output] | CREATE TABLE order_details ( product_no VARCHAR(20) NOT NULL, quantity INT NOT NULL, price DECIMAL(10,2) ); [instruction] | Design a MySQL table with 3 columns to store the order details [input] | The columns should include Product No, Quantity, and Price.
[output] | import numpy as np np.random.seed(0) # simulate the rolling of two fair six-sided dice outcomes = np.random.randint(1,7, size=(2,2)) print(outcomes) [instruction] | Write code using the NumPy random library to simulate the rolling of two fair six-sided dice. [input] |
[output] | dictionary = { 'A': 'Apple', 'B': 'Ball', 'C': 'Cat', 'D': 'Dog', 'E': 'Elephant', 'F': 'Fish', 'G': 'Goat', 'H': 'Horse', 'I': 'Ink', 'J': 'Jelly' } print(dictionary) [instruction] | Generate a dictionary with 10 elements and display it. [input] |
[output] | def find_largest_sum(arr): max_sum = 0 first_ele = arr[0] sec_ele = arr[1] for i in range(0, len(arr)): for j in range(i+1, len(arr)): curr_sum = arr[i] + arr[j] if curr_sum > max_sum: max_sum = curr_sum first_ele = arr[i] sec_ele = arr[j] return [f [instruction] | Given an array, find the 2 elements which have the largest sum. [input] | arr = [2, 8, 3, 5, 10, 1]
[output] | # Import sqlite3 module import sqlite3 # Connect to the Students.db database conn = sqlite3.connect('Students.db') # Create the Students table conn.execute(""" CREATE TABLE Students ( student_id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER NOT NU [instruction] | Write code to create an SQLite table called "Students" with 5 columns: student_id, name, age, class, and grade. [input] |
[output] | SELECT name, age FROM students WHERE age > 18; [instruction] | Generate a query to find the name and age of all students whose age is greater than 18. [input] |
[output] | def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) print(fibonacci(5)) # outputs 5 [instruction] | Implement a recursive function that finds the nth number in the Fibonacci sequence. [input] |
[output] | sentence = 'This is a sentence with extra white space.' sentence = sentence.replace(' ', '') print(sentence) # outputs 'Thisisasentencewithextrawhitespace.' [instruction] | Write a code to delete white space from this sentence. [input] | This is a sentence with extra white space.
[output] | <html> <head> <title>Page Title</title> </head> <body> <h1>My Table Webpage</h1> <table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>Row 1, Column 1</td> <td>Row 1, Column 2</td> </tr> [instruction] | Use HTML to create a webpage which featured a table. [input] |
[output] | <p style="font-family: Arial, sans-serif; font-size: 1.2em; color: #1a1a1a; line-height: 1.8em;">This is a sample paragraph.</p> [instruction] | Use CSS to style an HTML paragraph. [input] | <p> This is a sample paragraph. </p>
[output] | void bubbleSort(int arr[], int n) { int i, j; for (i = 0; i < n-1; i++) // Last i elements are already in place for (j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1]) swap(&arr[j], &arr[j+1]); } [instruction] | Use C++ to implement the bubble sort algorithm. [input] |
[output] | array = [[7, 8, 9], [7, 8, 9], [7, 8, 9]] def max_columns(array): for col in range(len(array[0])): m = array[0][col] for row in array: if row[col] > m: m = row[col] for row in range(len(array)): array[row][col [instruction] | Manipulate a 2D array in Python such that it consists of the maximum value of each column. [input] | array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[output] | <?php $string = "Hello World!"; echo strlen($string); ?> [instruction] | Write a PHP script to get the length of a string. [input] | string = "Hello World!"
[output] | let randomNumber = { getNumber: function() { return Math.floor(Math.random() * 10); } } let myNum = randomNumber.getNumber(); // Possible output: 5 [instruction] | Create an object in JavaScript which produces some random number when the object is called. [input] |
[output] | #include <iostream> int main() { int a = 3; int b = 3; a++; b++; int c = 10; std::cout << a << " " << b << " " << c << std::endl; return 0; } [instruction] | Discover and remove redundant code from this C++ program. [input] | #include <iostream> int main() { int a = 3; int b = 3; a++; b++; int c = 10; a++; b++; std::cout << a << " " << b << " " << c << std::endl; return 0; }
[output] | function printSquares(n) { for (let i = 1; i <= n; i++) { console.log(i*i) } } [instruction] | Create a function which prints out squares of all numbers from 1 to a given number in JavaScript. [input] |
[output] | SELECT DISTINCT job_title FROM employees; [instruction] | Create a SQL query to display unique job titles from the the table "employees"? [input] | Table name: employees Columns: employee_id, job_title
[output] | NaOH + H2SO4 → Na2SO4 + 2H2O. [instruction] | Balance the following reaction equation? [input] | NaOH + H2SO4 →
[output] | This Javascript code defines a function called 'addUser' which takes two parameters: username and age. It creates a 'user' object with the username and age as its properties and returns the object. [instruction] | Describe in English the function of this Javascript code. [input] | function addUser(username, age) { const user = { name: username, age: age }; return user; }
[output] | SELECT c.customer_name FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_cost > 100; [instruction] | Write a SQL query to get the names of all customers with orders that have a total cost greater than $100. [input] | Table names: customers, orders Table columns: customers(customer_id, customer_name), orders(order_id, customer_id, order_cost).
[output] | #include <iostream> using namespace std; class HelloWorld { public: HelloWorld() { cout << "Hello World!" << endl; } }; int main() { HelloWorld hw; return 0; } [instruction] | Create a C++ class to print the "Hello World!" string. [input] |