[output] | { "Root": { "item": ["A","B","C"] } } [instruction] | Parse the below XML into a JSON object. [input] | <Root> <item>A</item> <item>B</item> <item>C</item> </Root>
[output] | SELECT TableOne.ID, TableOne.Name, TableOne.Age, TableTwo.School FROM TableOne INNER JOIN TableTwo ON TableOne.ID = TableTwo.ID; [instruction] | Create a MySQL query to fetch data from two tables using an inner join. [input] | TableOne: ID, Name, Age TableTwo: ID, School
[output] | Scrapy is a Python framework used for web scraping. It can be used to extract data from websites using a variety of techniques. The first step is to create a Scrapy project and define the items you want to scrape. After that, create a Spider class which is responsible for crawling and extracting the [instruction] | How would you collect data from websites using Scrapy? [input] |
[output] | const celsiusToFahrenheit = celsius => { let fahrenheit = (celsius * 9/5) + 32; return fahrenheit; }; const tempCelsius = 20; const tempFahrenheit = celsiusToFahrenheit(tempCelsius); console.log(`${tempCelsius}°C is equal to ${tempFahrenheit}°F.`); [instruction] | Create a Node.js program for converting a temperature from Celsius to Fahrenheit. [input] |
[output] | db.collection.find({"_id": ObjectId("<id>")}); [instruction] | Create a query in MongoDB to search a record by its ID. [input] |
[output] | <?xml version="1.0" encoding="UTF-8"?> <data> <person> <name>Alice</name> <age>25</age> </person> <person> <name>Bob</name> <age>30</age> </person> </data> [instruction] | Convert the following JSON array to an XML document. [input] | [ { "name":"Alice", "age":25 }, { "name":"Bob", "age":30 } ]
[output] | CREATE TABLE customers ( id INT NOT NULL UNIQUE AUTO_INCREMENT, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, phone_number VARCHAR(20) NOT NULL, address VARCHAR(200) NOT NULL, PRIMARY KEY (id) ); [instruction] | Design a database schema for a table which stores customer information? [input] |
[output] | <form action=""> <label for="name">Name</label><br /> <input type="text" id="name" name="name" /><br /> <label for="email">E-Mail</label><br /> <input type="email" id="email" name="email" /><br /> <label for="feedback">Feedback</label><br /> <textarea id="feedback" name="feedback"></texta [instruction] | Build an online form for collecting customer feedback using HTML elements. [input] |
[output] | SELECT manager.name AS manager_name, department.name AS department_name FROM manager JOIN department ON manager.department_id = department.id; [instruction] | Write a MySQL query to retrieve the name of the manager and the department they manage. [input] |
[output] | public class SearchAlgorithm { public int search(int[] array, int target) { int left = 0; int right = array.length - 1; while (left <= right) { int mid = (left + right) / 2; if (target == array[mid]) { return mid; } if (target < array[mid]) { [instruction] | Implement a search algorithm in Java. [input] |
[output] | import hashlib string = "Hello World" result = hashlib.sha256(string.encode()).hexdigest() print(result) # output: "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e" [instruction] | Generate a hash of a given string using the SHA-256 algorithm in Python. [input] | string = "Hello World"
[output] | public class Car { private String make; private String model; private String color; //getters and setters public Car(String make, String model, String color) { this.make = make; this.model = model; this.color = color; } public String getMake() { [instruction] | Create an object of type Car in Java. [input] |
[output] | GET /customers Returns a list of customer objects GET /customers/{id} Returns customer info with the customer id POST /customers Add a new customer PUT /customers/{id} Update existing customer info with given customer id DELETE /customers/{id} Delete customer with given customer id [instruction] | Design a RESTful API that returns customer information. [input] |
[output] | curl -X GET http://example.com [instruction] | Create a cURL command that retrieves the contents of a webpage. [input] |
[output] | def loopRecursion(num): if(num<10): print("i:",num) loopRecursion(num+1) loopRecursion(0) [instruction] | Convert the following for loop to a recursive solution. [input] | for i in range(0, 10): print('i: ', i)
[output] | def find_pair(arr1, arr2): sum_arr1 = sum(arr1) sum_arr2 = sum(arr2) diff = abs(sum_arr1 - sum_arr2) for x in arr1: for y in arr2: if x + y == diff: return (x, y) return -1 [instruction] | Given two arrays of integers, find a pair of values (one from each array) that you can swap to give the two arrays the same sum. [input] | [1, 2, 3, 4], [3, 2, 1, 4]
[output] | def compute_equation(x): return x**2 + 3*x - 7 [instruction] | Write a code that computes the given equation for x. [input] | x2 + 3x - 7 = 0
[output] | def print_fibonacci(n): a = 0 b = 1 print('Fibonacci sequence:') while a < n: print(a, end=' ') tmp_var = a a = b b = tmp_var + b num = int(input("Enter positive number: ")) print_fibonacci(num) [instruction] | Create a Python program that accepts input from the user and prints out the result for Fibonacci sequence [input] |
[output] | fn main() { let arr = [6, 1, 4, 22, 7, 9]; let max_num: i32 = arr[0]; for x in 0..arr.len() { if arr[x] > max_num { max_num = arr[x]; } } println!("Max number: {}",max_num); } [instruction] | Create a RUST program that prints out the highest number from an array of integers. [input] | [6, 1, 4, 22, 7, 9]
[output] | def is_even(num): if num & 1 == 0: return True else: return False [instruction] | Write an algorithm to check if a number is even or not without using modulus (%) operator [input] |
[output] | public static int FindNthFibonacci(int n) { int firstNumber = 0, secondNumber = 1, result = 0; if (n == 0 || n == 1) return n; else { for (int i = 2; i <= n; i++) { result = firstNumber + secondNumber; firstNumber = secondNumber; [instruction] | Create a program in C# to find the nth Fibonacci number in the sequence. [input] |
[output] | #!/bin/bash echo "Folders and Sizes: " for item in `ls -l` do if [ -d $item ] then dirSize=`du -s $item | awk '{print $1}'` echo "$item : $dirSize" fi done [instruction] | Create a shell script to list out the folders and its size in the current directory [input] |
[output] | The formula for calculating the circumference of a circle is C = 2*π*r, where r is the radius of the circle. [instruction] | Derive the formula for calculating the circumference of a circle. [input] |
[output] | max_element = 56 [instruction] | Output the maximum element of a list [input] | list = [1, 23, 12, 38, 56, 9]
[output] | def calculate_value(nums): result = 0 for num in nums: # missing colon result += num return result [instruction] | Debug the following code by finding the syntax error. [input] | def calculate_value(nums): result = 0 for num in nums result += num return result
[output] | def reverse_list_elements(list_elements): list_elements.reverse() for element in list_elements: print(element) [instruction] | Create a function that takes in an array and displays all of the elements in the array in reverse order. [input] | list_elements = [15,19,20]
[output] | output_items = [item for item in list_items if len(str(item)) <= given_number] print(output_items) # Output [1, 2, 3] [instruction] | Output the items in a list with the length less than or equal to the given number. [input] | list_items = [1, 2, 3, 4, 5] given_number = 3
[output] | import re # Validate the email address using the regex email_pattern = re.compile(r'\S+@\S+\.\S+') email_valid = re.match(email_pattern, email) if email_valid: print("Valid Email Address") else: print("Invalid Email Address") # Output Valid Email Address [instruction] | Validate the email address using a regular expression. [input] | email = "example@gmail.com"
[output] | 32 [instruction] | What number is missing in the following sequence? [input] | 2, 4, 8, 16, __
[output] | index_of_item = my_list.index(item_to_find) # Output 2 [instruction] | What is the index of the item which is given below? [input] | my_list = [1, 2, 3, 4, 5] item_to_find = 3