[output] | .blueDiv { background-color: blue; font-size: 12px; } [instruction] | Write a CSS class to set the background of a div to blue and the font size to 12px. [input] |
[output] | colors = dict(items) [instruction] | Write code to create a dictionary from a list of tuples, where each tuple consists of a color name and its value. [input] | items = [("red", "#FF0000"), ("blue", "#0000FF")]
[output] | def filter_by(lst, criteria): """This function takes an array of elements and a criteria and returns an array of elements filtered by the criteria.""" return [x for x in lst if criteria(x)] [instruction] | Create a function to filter out elements in an array that meet a given criteria. [input] | lst = [2, 3, 4, 5, 6, 7, 8, 9] criteria = lambda x: x % 2 == 0
[output] | CREATE TRIGGER tr_storeTime BEFORE INSERT OR UPDATE ON <Table> FOR EACH ROW BEGIN IF INSERTING THEN SET NEW.addedTime = NOW(); END IF; IF UPDATING THEN SET NEW.updatedTime = NOW(); END IF; END; [instruction] | Create a MySQL trigger to store the times for insertion and updating a row in a table. [input] |
[output] | SELECT * FROM customers WHERE country = 'USA'; [instruction] | Write an SQL query to retrieve all records from a table named "customers" where the "country" column equals "USA". [input] |
[output] | SELECT * FROM orders WHERE status IN ('pending', 'shipped'); [instruction] | Write an SQL query to fetch all records from the 'orders' table, that have a status of either 'pending' or 'shipped'. [input] |
[output] | class BinarySearchTree: def __init__(self, value): self.left = None self.right = None self.value = value def inorder(self): if self.left: self.left.inorder() print(self.value) if self.right: self.right.inorder() [instruction] | Make a class in Python which will represent a binary search tree. [input] |
[output] | lambda x: [x for x in range(0, 11) if x % 3 == 0] [instruction] | Create a lambda function in Python that collects all the numbers between 0 and 10 that are divisible by 3. [input] |
[output] | HTML5 Canvas is an HTML element that can be used to draw graphics and animation with JavaScript scripts. It provides the ability to render graphics on the fly without the need for any plugins. Canvas elements are rendered as bitmap images which can be manipulated with code to create dynamic effects. [instruction] | What is HTML5 Canvas? [input] |
[output] | .styled-link { color: #00b3e6; text-decoration: none; font-weight: bold; } [instruction] | Create a CSS class to style an anchor tag. [input] |
[output] | p:first-of-type { /* styles go here */ } [instruction] | Write a CSS selector for selecting the first paragraph in any web page. [input] |
[output] | The Java keyword used to define a class is "class". [instruction] | Name the Java keyword used to define a class [input] |
[output] | sum_even_num = 0 for num in [1, 4, 6, 7, 8, 12, 19]: if num % 2 == 0: sum_even_num = sum_even_num + num print(sum_even_num) [instruction] | Find the sum of all even numbers in the following list (Python code): [input] | [1, 4, 6, 7, 8, 12, 19]
[output] | SELECT * FROM customers ORDER BY last_name; [instruction] | Write an SQL query to sort the customers in the table 'customers' alphabetically by their last name. [input] |
[output] | function validateIP(ipAddress) { let ipElements = ipAddress.split("."); if(ipElements.length !== 4) { return false; } for(let i=0; i<ipElements.length; i++) { let number = Number(ipElements[i]); if(number < 0 || number > 255) { return false; [instruction] | Create a JavaScript program to validate an IP address. [input] |
[output] | def count_fruits(apples, oranges): return apples + oranges [instruction] | Create a function that takes two arguments: the number of apples and oranges and returns the total number of fruits. [input] | apples = 3 oranges = 5
[output] | import random def get_random_number(): num = random.randint(-10, 10) if num < 0: num = -num return num [instruction] | Modify the following function to ensure that the number is always greater than zero. [input] | def get_random_number(): return random.randint(-10, 10)
[output] | String text = ""; text = "Hello World"; [instruction] | Insert a line of code to change the value of the string "text" to "Hello World". [input] | String text = "";
[output] | <table> <tr> <td>Column 1</td> <td>Column 2</td> <td>Column 3</td> </tr> <tr> <td>Row 1</td> <td>Row 1</td> <td>Row 1</td> </tr> <tr> <td>Row 2</td> <td>Row 2</td> <td>Row 2</td> </tr> <tr> <td>Row 3</td> <td>Row 3</td> <td>Row 3</td> < [instruction] | Create an HTML page displaying a table of 3 rows and 3 columns. [input] |
[output] | function printHello() { console.log("Hello!"); } printHello(); [instruction] | Translate the following Ruby code to Javascript [input] | def print_hello puts "Hello!" end print_hello
[output] | def search_list(string_list, search_term): """ Search a list for a given string and return its index. Parameters ---------- string_list : list The list to search search_term : str The string to search for Returns ------- index : int The i [instruction] | Search a list to find a string and return its index. [input] | string_list = ["apple", "banana", "orange"] search_term = "orange"
[output] | def compare_strings(string_1, string_2): if string_1 == string_2: return True else: return False [instruction] | Write a function to compare two strings. The function should return true if the strings are equal and false if the strings are not equal. [input] | string_1 = "Hello" string_2 = "World"
[output] | class Box: def __init__(self, width, length, height): self.width = width self.length = length self.height = height def calculate_volume(self): return self.width * self.length * self.height [instruction] | Write a class definition for a Box class. [input] |
[output] | 385 [instruction] | Calculate the sum of squares of the numbers till 10 [input] |
[output] | last_char = string[-1] print(last_char) [instruction] | Devise a Python code snippet to return the last character of a given string. [input] | string = "stackoverflow"
[output] | def long_increasing_subsequence(arr): # Number of items in given array n = len(arr) # Initialize 'lengths' values for all indices lengths = [1]*n # Find the longest increasing subsequence for i in range(1, n): for j in range(i): if arr[j] < arr[i] and [instruction] | Design a Python program to find the longest increasing subsequence in a given array. [input] |
[output] | from collections import Counter def get_most_frequent_value(mylist): counted_list = Counter(mylist) return counted_list.most_common(1)[0][0] most_frequent_value = get_most_frequent_value(mylist) print(most_frequent_value) # Output # 4 [instruction] | Find the most frequent value in a list [input] | mylist = [1,2,3,4,4,4,4,5,5]
[output] | for i in range(10): print('hello') [instruction] | Create a loop that prints 'hello' 10 times when ran. [input] |
[output] | /hello\s+people/ [instruction] | Write a regular expression to match the phrase "hello people" [input] |
[output] | def generate_primes(n): prime_list = [] for num in range(2, n + 1): if all(num % i != 0 for i in range(2, num)): # check if num is prime prime_list.append(num) return prime_list [instruction] | Generate a list of prime numbers [input] |