[output] | if x > 10: print("x is greater than 10.") [instruction] | Translate the following statement from English to Python code: "If the value of x is greater than 10, print 'x is greater than 10." [input] |
[output] | console.log("Print this message"); [instruction] | Write a JavaScript statement to log a string onto the console. [input] | String: "Print this message"
[output] | body { font-weight: bold; } [instruction] | Write a CSS rule to make all text appear in bold font. [input] |
[output] | Install Django using pip by running the following command from the command line: pip install Django You can also install Django from source: git clone https://github.com/django/django.git cd django python setup.py install [instruction] | How do you install the Django web framework? [input] |
[output] | SELECT first_name, last_name, email FROM customers; [instruction] | Write an SQL query to select only the first name, last name, and email columns from a table named 'customers'. [input] |
[output] | Setting up a local development environment for a Node.js application involves installing a compatible version of Node.js and setting up the necessary modules. After installation, node’s package manager, NPM, can be used to install the packages and dependencies for the application. Additionally, an I [instruction] | How do you set up a local development environment for a Node.js application? [input] |
[output] | One way to filter out comments containing profane language in a text corpus is to use a rule-based algorithm with a list of profane words and phrases. This algorithm can be configured to identify words or phrases in a given corpus that match the list of profane words and phrases, and flag them as in [instruction] | Suggest a way to filter out comments containing profane language in a text corpus. [input] |
[output] | class Product: """ A class that represents a product with its attributes. """ def __init__(self, name, price, description): """ Initialize a Product object. """ self.name = name self.price = price self.description = description [instruction] | Create a class called 'Product' in Python and assign the following attributes to it. [input] | name, price, description
[output] | Cross-validation is a technique used to evaluate a machine learning model by dividing the dataset into training and validation sets. The model is trained on the training set, and its performance is evaluated on the validation set. In other words, cross-validation is a method for selecting model hype [instruction] | Explain what is Cross-validation in Machine Learning. [input] |
[output] | import requests from bs4 import BeautifulSoup def get_page_title(url): """ This function makes an HTTP request to the given URL and extracts the title of the web page. """ response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') return soup.title.st [instruction] | Write a script in Python to make an http request and extract the title of the web page. [input] | url = 'https://en.wikipedia.org/wiki/Deep_learning'
[output] | One way to generate random passwords using Python is to use the string module's methods. Using the string.ascii_letters and string.digits sequences, we can create a random sequence of alphanumeric characters. The string module's choice() function can then be used to randomly select characters from t [instruction] | Suggest a way to generate random passwords using Python. [input] |
[output] | const convertRGBtoHEX = (rgb) => { let hex = ''; switch (rgb) { case (rgb[0], rgb[1], rgb[2]): hex = (rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16); break; default: hex = "000000"; break; } return hex; } console.log [instruction] | Create a switch statement to convert an RGB value to HEX. [input] | rgb = (255, 205, 100)
[output] | for i in range(0, 21): if i % 2 == 0: print(i) [instruction] | Construct a loop that prints the even numbers from 0 to 20, one number per line. [input] |
[output] | SELECT category, COUNT(*) AS items FROM items GROUP BY category; [instruction] | Write an SQL query that returns the total number of items per category. [input] |
[output] | # 6ba62f1bf [instruction] | Generate a unique 9-digit hexadecimal code. [input] |
[output] | def addItems(arr): total = 0 for number in arr: total = total + number return total [instruction] | Create a function that takes an array as a parameter and continuously adds each item to the total sum. [input] | arr = [6, 4, 3, 10]
[output] | # 3 [instruction] | Count the number of occurrences of the letter “a” in a given string. [input] | string = "My favorite animal is a dog"
[output] | #include<iostream> using namespace std; // Finds the average of given 10 numbers float Average(int arr[]) { float sum = 0; for (int i=0; i<10; i++) { sum = sum + arr[i]; } return (sum/10); } // Driver program to run above function int main() { [instruction] | Write a C++ program to make an average of given 10 numbers. [input] | arr = [3, 5, 8, 10, 14, 16, 22, 27, 33, 44]
[output] | <ul> <li>Lettuce</li> <li>Carrot</li> <li>Cucumber</li> </ul> [instruction] | Transform the following array into an HTML unordered list. [input] | const veggies = ["Lettuce", "Carrot", "Cucumber"]
[output] | const isWholeNumber = (num) => { if (num % 1 === 0) return true return false } [instruction] | Write a JavaScript function to check if a number is a whole number or has decimals. [input] |
[output] | Function B should call function A, since function A is the one that provides the data for the processing done by function B. [instruction] | Should function A call function B or function B call function A? [input] | A: function getData() { // do something return data; } B: function processData(data) { // do something return processedData; }
[output] | let arr = [9, 5, 7, 11, 2]; function bubbleSort(arr) { let swapped; do { swapped = false; for (let i = 0; i < arr.length; i++) { if (arr[i] > arr[i+1]) { let temp = arr[i]; arr[i] = arr[i+1]; arr[i+1] = temp; swapped = true; } } } [instruction] | Perform a bubble sort on the following array of numbers. [input] | const arr = [9, 5, 7, 11, 2]
[output] | list_of_strings = ["John", "Bob", "Jill", "Sara"] for name in list_of_strings: print(name) [instruction] | Create a for loop that prints the contents of a list of strings. [input] | list_of_strings = ["John", "Bob", "Jill", "Sara"]
[output] | # Find the longest word in a piece of text # Split the text into a list of words words = "The quick brown fox jumps over the lazy dog".split() # Initialize a variable to keep track of the longest word longest_word = "" # Loop over each word in the list for word in words: # Check if the curre [instruction] | Find the longest word in a piece of text. [input] | The quick brown fox jumps over the lazy dog
[output] | # Create program that assigns an ID to each element of an array arr = ["Car", "Bike", "Bus"] # Initialize a counter counter = 0 # Loop over each element of the array for element in arr: # Assign an ID to the element (in this case, the counter value) element_id = counter # Print the a [instruction] | Create a program that assigns an ID to each element of an array. [input] | arr = ["Car", "Bike", "Bus"]
[output] | The factorial of 5 is 1 [instruction] | What is the factorial of 5? [input] |
[output] | import random def rand_num(): return random.randint(1, 100) [instruction] | Implement a random number generator in Python that returns a random number in the range of 1-100. [input] |
[output] | def longest_palindrome(string): # Create an empty substring longest_substring = '' # Iterate through the string for i in range(len(string)-1): for j in range(i+1, len(string)): substring = string[i:j+1] if substring == substring[::-1] and len(sub [instruction] | Find the longest substring of two characters that is a palindrome. [input] | string = "banana"
[output] | class MyClass: def __init__(self): pass def add(self, x, y): return x + y def subtract(self, x, y): return x - y def multiply(self, x, y): return x * y def divide(self, x, y): return x / y [instruction] | Create a class in Python and define several functions for that class. [input] |
[output] | def find_max_difference(nums): # Initialize a max difference max_diff = float('-inf') # Iterate through the array for i in range(1, len(nums)): diff = nums[i] - nums[i-1] if diff > max_diff: max_diff = diff return max_diff # Call the functio [instruction] | Given an array of integers, write an algorithm to find the maximum difference between any two elements in the array. [input] | nums = [3, 2, 7, 1, 4]