[output] | dedicated, tried [instruction] | Find all words that contain the string "ed" in the provided text. [input] | She's a very dedicated person, who always tries to get the job done.
[output] | list_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [instruction] | Write Python code to create a list of numbers from 1 to 10 (including 10). [input] |
[output] | my_dict = {"name": "", "age": 0} [instruction] | Create a dictionary containing the keys "name" and "age". [input] |
[output] | class Person: def __init__(self, name, age, address): self.name = name self.age = age self.address = address [instruction] | Create a class named "Person" containing the data members "name", "age", and "address". [input] |
[output] | def longest_substring(str): seen = {} start = 0 maxlen = 0 for i, char in enumerate(str): if char in seen: start = max(start, seen[char] + 1) seen[char] = i maxlen = max(maxlen, i - start + 1) return maxlen print(longest_subs [instruction] | Given a string, find the longest substring containing no repeated characters. [input] | "abcabcbb"
[output] | import requests trends_url = "https://api.twitter.com/1.1/trends/place.json?id=1" headers = { 'Authorization': ' [instruction] | Make an API request to fetch the top 3 trending topics from Twitter. [input] |
[output] | def union(A, B): union_set = set() for item in A: union_set.add(item) for item in B: union_set.add(item) return union_set [instruction] | Given two sets, A and B, write a program to find the union of the two. [input] | A = {1, 2, 3, 4, 5} B = {3, 4, 5, 6, 7}
[output] | def nth_prime(n): if n == 0: return None primeCount = 0 checkNum = 2 while(primeCount < n): isPrime = True for i in range(2, checkNum): if checkNum % i == 0: isPrime = False if isPrime == True: prim [instruction] | Given a number n, write a program to find the nth prime number. [input] |
[output] | def fibonacci(n): if n <= 0: return None first = 0 second = 1 sequence = [first, second] for i in range(2, n): next_term = first + second sequence.append(next_term) first = second second = next_term return sequence [instruction] | Given a starting number, write a program to generate the Fibonacci sequence up to nth number. [input] |
[output] | #include <iostream> #include <string> int main() { std::string text = "Hello World!"; std::string reversed = ""; for (int i=text.length()-1; i>=0; i--) { reversed = reversed + text[i]; } std::cout << reversed << std::endl; return 0; } [instruction] | Write a C++ program that takes a string, reverses the string and prints it out. [input] | text = "Hello World!"
[output] | for (const movie of movies) { if (movie["rating"] >= 8) { std::cout << movie["title"] << std::endl; } } // Output: // Toy Story 4 // Joker // Avengers: Endgame [instruction] | In the accompanying array containing movie ratings, print out only the movies with ratings 8 or greater. [input] | movies = [ {"title": "Toy Story 4", "rating": 8}, {"title": "Joker", "rating": 9}, {"title": "The Lion King", "rating": 7}, {"title": "Avengers: Endgame", "rating": 8}, ]
[output] | for element in my_list: print(element) [instruction] | Write a code that uses a for-loop to print out the elements of the following array: [input] | my_list = [1,2,3,4]
[output] | even_numbers = [] for number in my_array: if number % 2 == 0: even_numbers.append(number) print(even_numbers) [instruction] | Write a code to filter the even numbers from the following array: [input] | my_array = [1,2,3,4,5,6]
[output] | even_numbers = [] for number in my_array: if number % 2 == 0: even_numbers.append(number) average = sum(even_numbers) / len(even_numbers) print(average) [instruction] | Enhance the following code to find the average of all the even numbers in the array: [input] | my_array = [1,2,3,4,5,6]
[output] | import re text = '\thello \tworld \t' text = re.sub('\t', ' ', text) print(text) [instruction] | Use expand tabs to replace all the tabs in the following text with four spaces. [input] | text = '\thello \tworld \t'
[output] | The dependent clause "who was once young and strong" is restrictive as it limits the definition of the noun phrase to a specific group. This particular group is elderly women who were once young and strong. [instruction] | Analyze the following sentence and determine whether the dependent clause is restrictive or nonrestrictive. [input] | The elderly woman, who was once young and strong, works every day.
[output] | import java.util.LinkedHashSet; public class DuplicateWords { public static void findDuplicates(String str) { String[] words = str.split("\\s+"); LinkedHashSet<String> set = new LinkedHashSet<>(); for (int i = 0; i < words.length; i++) { if (!set.add(words[i] [instruction] | Create a Java program to list all duplicated words in the given string. [input] | He explained the problem in an intelligent and articulate manner.
[output] | DELETE t1 FROM TableA t1 INNER JOIN TableB t2 ON t1.name = t2.name AND t1.age = t2.age; INSERT INTO TableA (id, name, age) SELECT id, name, age FROM TableB; [instruction] | Write a SQL query to combine two tables into one and delete the duplicate rows. [input] | Table A: id | name | age 1 | John | 20 2 | Mary | 22 3 | Jane | 19 Table B: id | name | age 4 | Mark | 25 5 | John | 20 6 | Jack | 15
[output] | SELECT AVG(salary) FROM Employees; [instruction] | Create a SQL query to compute the average salary of the employees. [input] |
[output] | int result; switch (a) { case 0: result = b * c; break; case 1: result = b + c; break; case 2: result = b - c; break; default: break; } [instruction] | Rewrite the following code snippet using a switch-case statement. [input] | if (a == 0) { result = b * c; } else if (a == 1) { result = b + c; } else { result = b - c; }
[output] | The code snippet is an example of the Template Method pattern. It provides a template method (eat, move, and sleep) that can be used by subclasses. The template method is defined in a superclass and the subclasses can override the methods to provide custom implementations. [instruction] | Identify the type of object-oriented programming pattern used in the following code snippet. [input] | public class Animal { public void eat() { // eat logic } public void move() { // move logic } public void sleep() { // sleep logic } }
[output] | div h1 { // styles here } [instruction] | Write a CSS selector to select all the <h1> elements inside a <div> element. [input] |
[output] | SELECT STDDEV(Grade) FROM StudentTable; [instruction] | Write a SQL query to calculate the standard deviation of student grades from the following table. [input] | Student | Grade John | 75 Mary | 85 Bob | 80 Jane | 90
[output] | The verb phrase in this sentence is a perfect verb phrase, as it indicates an action that has been completed in the past and has a continuing result in the present. The verb in the phrase is "have met". [instruction] | Analyze the following sentence to determine the type of verb phrase involved. [input] | We have met several times.
[output] | SELECT firstName FROM students WHERE courseName = 'CSCI-203'; [instruction] | Write a SQL query to find the first name of all students enrolled in course "CSCI-203" [input] |
[output] | JSONObject jsonObj = new JSONObject(jsonInput); // get the data JSONObject data = jsonObj.getJSONObject("data"); // get the users list JSONArray users = data.getJSONArray("users"); // traverse the users list for(int i=0;i<users.length();i++){ JSONObject user = users.getJSONObject(i); Stri [instruction] | Parse this JSON string into a JSONObject [input] | { "status": 200, "message": "OK", "data": { "users": [ { "name": "John", "age": 20 }, { "name": "Ken", "age": 30 } ] } }
[output] | "{\"name\": \"John\", \"age\": 20}" [instruction] | Format the following string to a valid JSON [input] | {name: "John", age: 20}
[output] | INSERT INTO tbl_users (user_name, user_email) VALUES ('John Doe', 'john@example.com'); [instruction] | Write SQL code to insert a row into this table called "tbl_users". [input] | Table Structure: tbl_users user_id (int, primary key) user_name (varchar) user_email (varchar)
[output] | const csvInput = `name, age John, 20 Ken, 30`; const lines = csvInput.split('\n'); const header = lines[0].split(', '); const rows = lines.slice(1); const objects = []; rows.forEach(row => { const entries = row.split(', '); const obj = {}; header.forEach((key, i) => { obj[key] [instruction] | Process this CSV string into an array of objects. [input] | name, age John, 20 Ken, 30
[output] | def isAnagram(string1, string2): # get lengths of strings string1_length = len(string1) string2_length = len(string2) # if length dont match if string1_length != string2_length: return False # sorting both strings string1 = sorted(string1) string2 [instruction] | Read two strings from the user and check if they are anagrams. [input] | string1 = 'listen', string2 = 'silent'