[output] | db.collection.find({ $text: { $search: "query" } }) [instruction] | Create a MongoDB query that returns all documents that contain the string "query". [input] |
[output] | <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>Heading</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </body> </html> [instruction] | Write an HTML page that displays one heading and two paragraphs. [input] |
[output] | x <- seq(from = 0, to = 50, by = 4) print(x) [instruction] | Write an R program to print out the numbers from 0-50, in steps of 4. [input] |
[output] | <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <button>A</button> <button>B</button> <button>C</button> </body> </html> [instruction] | Create an HTML page that includes three buttons with labels "A", "B" and "C". [input] |
[output] | set.seed(1234) runif(5, min = 0, max = 1) [instruction] | Write an R program to generate 5 random numbers between 0 and 1. [input] |
[output] | ^\d{10}$|(^\d{3}\-\d{3}\-\d{4}$)|(^\(\d{3}\) \d{3}\-\d{4}$) [instruction] | Create a valid regular expression that matches a valid U.S. phone number? [input] |
[output] | def Fibonacci(n): if n<0: print("Incorrect input") elif n==1: return 0 elif n==2: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) [instruction] | Write a function that calculates the Fibonacci numbers to the nth number [input] |
[output] | const Calculator = { add: function(a, b) { return a + b; }, subtract: function(a, b) { return a - b; }, multiply: function(a, b) { return a * b; }, divide: function(a, b) { return a / b; }, }; [instruction] | Create a JavaScript object to fulfill the following purpose [input] | Create a calculator that can add, subtract, multiply and divide two numbers.
[output] | def get_longest_palindrome(s): longest_palindrome = '' s_length = len(s) for i in range(s_length): for j in range(i, s_length): substring = s[i:j + 1] if len(substring) > len(longest_palindrome) and substring == substring[::-1]: longest_pal [instruction] | Write a code to identify the longest palindrome in a given string [input] | String: kayakracecar
[output] | transform: rotate(45deg); [instruction] | Create a CSS rule to rotate a text 45 degrees [input] |
[output] | def get_longest_sentence(text): sentences = text.split('. ') longest_sent_len = 0 longest_sent = '' for sentence in sentences: if len(sentence) > longest_sent_len: longest_sent_len = len(sentence) longest_sent = sentence return longest_sent_len # [instruction] | Write a code to extract the length of the longest sentence in a given text [input] | Text: The quick brown fox jumps over the lazy dog. The quick fox jumped over the lazy dog.
[output] | <!DOCTYPE html> <html> <head> <title>Two Text Fields and Two Buttons</title> </head> <body> <form action=""> <input type="text" placeholder="Input 1" /> <input type="text" placeholder="Input 2" /> <button type="submit">Button 1</button> <button type="reset">Butt [instruction] | Create an HTML web page that contains two text fields and two buttons [input] |
[output] | def FibonacciSum(n): fib1 = 0 fib2 = 1 if n < 0: return "Incorrect input" elif n == 0: return 0 elif n == 1: return 0 else: sum = 0 for i in range(2,n+1): fib_n = fib1 + fib2 fib1 = fib2 fib2 = f [instruction] | Create a function that returns the sum of the Fibonacci sequence to the nth number [input] |
[output] | [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] [instruction] | Use recursion to construct a list of the first 10 powers of two (1, 2, 4, 8, ...). [input] |
[output] | regex: \bapple\b [instruction] | Using the given sentence, design a regular expression which will match the given word. [input] | Word: apple Sentence: I bought an apple from the store.
[output] | Element: 7 [instruction] | Find the 4th element in the given expression. [input] | list x=[1,3,5,7,9,8]
[output] | <html> <head> <title>My web page</title> </head> <body> <h1>My web page</h1> <p>This is my web page.</p> <p>It contains some information about me.</p> </body> </html> [instruction] | Use the given HTML markup to generate a web page with a headline, body and paragraphs. [input] | <h1>My web page</h1>
[output] | Sorted Array: ['hi', 'hello', 'howdy'] [instruction] | Sort the given array of strings by their length. [input] | Array: ['hello', 'hi', 'howdy']
[output] | Inverted dictionary: {1: 'a', 2: 'b', 3: 'c'} [instruction] | Invert the given dictionary. [input] | Dictionary: {'a': 1, 'b': 2, 'c':3}
[output] | Username: johnsmith Domain name: example.com [instruction] | Extract the username and domain name from the given email address. [input] | Email address: johnsmith@example.com
[output] | class CapitalizedWord: def __init__(self, word): self.word = word def get_capitalized_word(self): return self.word[0].upper() + self.word[1:] [instruction] | Construct a class that takes a string and capitalizes the first letter. [input] |
[output] | class Circle: def __init__(self, radius): self.radius = radius def calculate_area(self): return 3.14 * self.radius * self.radius def calculate_circumference(self): return 2 * 3.14 * self.radius [instruction] | Design a class named Circle that can store information about a circle and perform calculations on it. [input] |
[output] | def find_words(words, given_string): count = 0 for word in words: if word == given_string: count += 1 return count if __name__ == '__main__': words = ['hello', 'hi', 'world', 'foo', 'bar', 'hello'] given_string = 'hello' print(find_words(words, given_stri [instruction] | Create a function that takes two arguments, a list of strings and a string and returns the number of times the passed in string appears in the list. [input] | words = ['hello', 'hi', 'world', 'foo', 'bar', 'hello'] given_string = 'hello'
[output] | def is_anagram(str1, str2): if (sorted(str1)== sorted(str2)): return True else: return False if __name__ == '__main__': str1 = 'martha' str2 = 'hartma' print(is_anagram(str1, str2)) [instruction] | Write a code that takes in two strings that are anagrams of each other and determines whether they are anagrams. [input] | str1 = 'martha' str2 = 'hartma'
[output] | def is_anagram(str1, str2): if (sorted(str1)== sorted(str2)): return True else: return False if __name__ == '__main__': str1 = input("Input string 1: ") str2 = input("Input string 2: ") print(is_anagram(str1, str2)) [instruction] | Create a program which takes two strings and checks if they are anagrams of one another. [input] | Input string 1: eats Input string 2: seat
[output] | $('.my-button').click(function(){ // Code here }); [instruction] | Using jQuery, write a snippet to add a click event handler to a given HTML element. [input] | #html element <div class="my-button">Click Me!</div>
[output] | let result = []; let max = arr[0]; result.push(max); for (let i = 1; i < arr.length; i++) { let min = Math.min(max, arr[i]); result.push(min); max = min; } console.log(result); # Output: [5, 4, 3, 2, 1] [instruction] | Write a JavaScript program to create an array with the first element as the maximum and all other elements as the minimum value of the previous element. [input] | let arr = [5, 4, 3, 2, 1];
[output] | let color = "#"; let characters = '0123456789ABCDEF'; for (let i = 0; i < 6; i++) color += characters[Math.floor(Math.random() * 16)]; console.log(color); # Output: #6f435a [instruction] | Write a JavaScript program to generate a random aluminum hexadecimal color code. [input] |
[output] | public static int countOddNumbers(int start, int end) { int count = 0; for (int i = start; i <= end; i++) if (i % 2 != 0) count++; return count; } System.out.println(countOddNumbers(start, end)); # Output: 5 [instruction] | Using Java, write a function to find the count of all odd numbers between a given range. [input] | int start = 1; int end = 10;
[output] | <html> <head> </head> <body> Hello World! </body> </html> [instruction] | Create an HTML page that displays the following text in the body: "Hello World!". [input] |