[output] | h1 { font-size: 2em; color: #444; } p { font-size: 1em; color: #666; } a { color: #069; text-decoration: none; } [instruction] | Create a CSS stylesheet and include styles for basic elements such as headings, paragraphs, and links. [input] |
[output] | import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/welcome") pub [instruction] | Create a Java web application that displays a welcome message. [input] |
[output] | import re text = "The conference will be held on Wednesday, June 16th, 2021" # Extract dates dates = re.findall(r'\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}',text) # Print the dates for date in dates: print(date) # Output # 06/16/2021 [instruction] | Parse and extract the dates from a given text. [input] | The conference will be held on Wednesday, June 16th, 2021
[output] | # Function to find elements in an array that is # divisible by a given number def isDivisible(arr, num): # Stores result res = [] # Iterate over all elements for i in range(0,len(arr)): # If remainder is 0 then add elements # to result if (ar [instruction] | Write a code to find elements in an array that is divisible by a given number. [input] | arr = [5, 15, 20, 25, 30]
[output] | import React from 'react'; class SortComponent extends React.Component { constructor(props) { super(props); this.state = { strings: this.props.strings }; } // sorting function sort = (strings) => { return strings.sort(); } render() { let sortedStrings = t [instruction] | Create a React component to sort an array of strings. [input] | arr = ["test", "data", "string"]
[output] | def most_frequent(nums): # Initialize a dictionary to count the frequency # of each number in the list count = {} # Iterate through the list and increase the # count of each number in the dictionary for num in nums: if num> 100: if num not in count: [instruction] | Write a code snippet to find the most frequent number greater than 100 from a list of numbers. [input] | [102, 130, 102, 140, 150, 60, 70, 102, 140]
[output] | function trueFalseRatio(arr){ let trueCount = 0; let falseCount = 0; arr.forEach(val => { if(val === 0){ falseCount++; } else { trueCount++; } }); return { true: trueCount, false: falseCount }; } [instruction] | Write a JavaScript function to compute the true false ratio of a given array. [input] | [0, 1, 1, 0, 0]
[output] | def cubeArrayElements(arr): for i in range(0, len(arr)): arr[i] = arr[i]*arr[i]*arr[i] return arr [instruction] | Create a code to update the values of an array elements with their cube. [input] | [1, 2, 3, 4, 5]
[output] | db.collection.find({ "category": "clothes" }) [instruction] | Write a MongoDB query to select all documents in a collection where the field 'category' is 'clothes'. [input] |
[output] | The hypotenuse of a right triangle with sides 4 and 5 is 6.40312. [instruction] | Calculate the hypotenuse of a right triangle when the other two sides are 4 and 5. [input] |
[output] | def add_two_numbers(x, y): # Compute and return the sum of two numeric inputs return x + y [instruction] | Edit the code given below so it can compute the sum of two numeric inputs. [input] | def add_two_numbers(x, y): # TODO: Write code that computes and returns the sum of two numeric inputs
[output] | from sklearn.neighbors import KNeighborsClassifier X = df.iloc[:,:-1].values y = df.iloc[:,-1].values knn = KNeighborsClassifier(n_neighbors=3) knn.fit(X, y) [instruction] | Using the given datasets and Scikit-Learn, develop a K Nearest Neighbors (KNN) classifier. [input] | import pandas as pd df = pd.read_csv("data.csv")
[output] | const groupOfThree = (arr) => { const chunks = []; let i; for (i = 0; i < arr.length; i+=3) { chunks.push(arr.slice(i, i+3)); } return chunks; } console.log(groupOfThree([1, 4, 7, 9, 12, 16, 19])); // Output: [[1,4,7], [9,12,16], [19]] [instruction] | Group the objects of an array into bunches of 3 using JavaScript. [input] | [1, 4, 7, 9, 12, 16, 19]
[output] | #include <tuple> #include <vector> template<typename Items> auto list_to_tuple(const Items& items) { std::tuple<Items> result; std::copy(items.begin(), items.end(), std::tuple_cat(result)); return result; } [instruction] | Write a function in C++ to convert a list to a tuple. [input] |
[output] | const parsedObject = JSON.parse('{ "name": "John", "age": 30, "city": "New York" }'); console.log(parsedObject); // Output: {name: "John", age: 30, city: "New York"} [instruction] | Using the given JSON string, parse the string and convert it into an object or array in JavaScript [input] | { "name": "John", "age": 30, "city": "New York" }
[output] | const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('<p>This is the homepage</p>'); }); app.listen(3000, () => { console.log('Server is listening at port 3000'); }); [instruction] | Create a Node.js express server to serve a web page when the root route is requested. [input] |
[output] | [x for x in range(41, 100) if x % 7 == 0] # Output: [42, 49, 56, 63, 70, 77, 84, 91, 98] [instruction] | Generate a list of 10 numbers in Python where each number is a multiple of 7 and greater than 40 [input] |
[output] | negative [instruction] | Classify the given text as "positive" or "negative" using Natural Language Processing. [input] | This movie is terrible.
[output] | const strList = [ "name": "John", "age": 30, "city": "New York" ]; const strDict = {}; for (i = 0; i < strList.length; i++) { const keyValue = strList[i].split(': '); strDict[keyValue[0]] = keyValue[1]; } console.log(strDict); // Output: { name: "John", age: 30, city: "New York" } [instruction] | Reorganize the given list of strings into a dictionary in JavaScript. [input] | [ "name": "John", "age": 30, "city": "New York" ]
[output] | public static String reverseString(String s) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) { sb.append(s.charAt(i)); } return sb.toString(); } [instruction] | Write a method in Java to return a reversed version of a given string. [input] |
[output] | <form action="contactinfo.php" method="POST"> <label>Name</label> <input type="text" name="name" /> <label>Email</label> <input type="text" name="email" /> <label>Phone Number</label> <input type="text" name="phone" /> <input type="submit" value="Submit" /> </form> [instruction] | Create an HTML form to allow a user to enter their contact information. [input] | Fields requested: Name, Email, Phone number
[output] | class Point2D { private: double x; double y; public: Point2D(double x_coordinate, double y_coordinate); double get_x(); double get_y(); }; Point2D::Point2D(double x_coordinate, double y_coordinate) { x = x_coordinate; y = y_coordinate; } double Point2D::get_x() [instruction] | Create a C++ object to represent a 2D point. [input] |
[output] | INSERT INTO Employees (Name, Age, Job_Title) VALUES ('John', 28, 'Programmer'), ('Alice', 24, 'Designer'); [instruction] | Write a MySQL query to insert new records in an 'Employees' table. [input] | Table Name: Employees Records to add: Name: John, Age: 28, Job Title: Programmer Name: Alice, Age: 24, Job Title: Designer
[output] | <html> <head> <title>Biography of Marie Curie</title> </head> <body> <h1>Marie Curie</h1> <p>Marie Curie (1867-1934) was a Polish physicist and chemist who conducted pioneering research on radioactivity and discovered the elements radium and polonium. She was twice awarded the Nobe [instruction] | Create a web page that shows a short biography of the given person. [input] | Person: Marie Curie
[output] | total = 0 for number in [2, 3, 6, 4, 8]: total += number print("Total: ", total) # Output: Total: 23 [instruction] | Sum up the values in the given list using a for loop. [input] | List: [2, 3, 6, 4, 8]
[output] | def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position j = i-1 while j >= 0 and key < arr[j] : [instruction] | Perform an insertion sort on the given list. [input] | List: [9, 5, 4, 8, 6]
[output] | let list = [1, 9, 45, -5, 23, 18]; let smallest = Math.min(...list); let largest = Math.max(...list); console.log("Smallest: " + smallest + ", Largest: " + largest); [instruction] | Given a list of integers, find the smallest and the largest of the set. [input] | [1, 9, 45, -5, 23, 18]
[output] | const jsonStr = '{"name": "John", "age": 30, "likes": ["sports", "chess"]}'; let jsonObj = JSON.parse(jsonStr); for (let key in jsonObj) { console.log(`${key}: ${jsonObj[key]}`); } [instruction] | Parse a JSON string and print each key-value pair to the console. [input] | '{"name": "John", "age": 30, "likes": ["sports", "chess"]}'
[output] | #!/bin/bash if [ $# -eq 0 ]; then echo "Error: No arguments supplied." exit 1 fi ip=$( dig +short $1 ) echo $ip [instruction] | Implement a shell script to retrieve the IP address of a website. [input] |
[output] | let regex = /^Hello/; [instruction] | Create a regular expression that matches strings starting with "Hello". [input] |