[output] | A possible approach to filter out unwanted words from a given paragraph of text is to use a hash table or dictionary. By creating a dictionary using key-value pairs of words and their frequencies, it becomes possible to compare the words found in a given text against the words in the dictionary to d [instruction] | Suggest an appropriate algorithm to filter out unwanted words from a given paragraph of text. [input] |
[output] | def alphabetical_sort(lst): sorted_list = sorted(lst, key=lambda x: x.lower()) return sorted_list [instruction] | Create a function to sort items in a list alphabetically in Python. [input] |
[output] | SELECT * FROM books WHERE genre = 'fiction' AND title LIKE '%cat%'; [instruction] | Create a SQL query to find all books in the "fiction" genre whose titles contain the word "cat". [input] |
[output] | A popular sorting approach for an array of numbers using JavaScript is the Quicksort algorithm. This algorithm partitions an array into two smaller subarrays and then recursively applies the same partitioning process on the subarrays. The Quicksort algorithm is an efficient sorting algorithm with a [instruction] | Suggest an appropriate approach to sort an array of numbers using JavaScript. [input] |
[output] | SELECT author FROM books WHERE id IN (SELECT author FROM books GROUP BY author HAVING COUNT(*) >= 3); [instruction] | Generate a SQL query to select all authors who have written at least 3 books. [input] |
[output] | The top ten earning authors are: [Names] [instruction] | Write a SQL query to find the names of the top 10earning authors. [input] | SELECT Name FROM Authors ORDER BY earnings DESC LIMIT 10
[output] | def selection_sort(list): for i in range(len(list)): min_idx = i for j in range(i+1, len(list)): if list[min_idx] > list[j]: min_idx = j list[i], list[min_idx] = list[min_idx], list[i] return list # example list = [9, 5, 3, 1, 8] [instruction] | Implement selection sort to sort a list in non-decreasing order [input] | list = [9, 5, 3, 1, 8]
[output] | def pow_n_m(n, m): result = 1 for i in range(1, m+1): result *= n return result # example n = 3 m = 7 print(pow_n_m(n, m)) [instruction] | Generate a code to find the power of n to m. [input] | n = 3, m = 7
[output] | def most_frequent_char(s): counts = {} max_char = "" max_count = 0 for c in s: if c in counts: counts[c] += 1 else: counts[c] = 1 if counts[c] > max_count: max_char = c max_count = counts[c] return max_char [instruction] | Create a code to calculate the most frequent character in a given string [input] | s = "Hello world!"
[output] | def capitalize_sentences(text): sent_list = text.split(".") cap_sent_list = [sentence.capitalize() for sentence in sent_list] output = '.'.join(cap_sent_list) return output [instruction] | Create a simple program to capitalize the first letter of every sentence [input] |
[output] | def num_occurrences(text, word): count = 0 words = text.split() for w in words: if w == word: count += 1 return count [instruction] | Given a text string, generate a Python code snippet to find the number of occurrences of a given word [input] | The quick brown fox jumped over the lazy dog
[output] | ([\w.-]+)@([\w.-]+) [instruction] | Generate a regular expression to extract the domain from an email address [input] |
[output] | class Cat: def __init__(self, name, color, age): self.name = name self.color = color self.age = age def eat(self): print(f"{self.name} is eating") def sleep(self): print(f"{self.name} is sleeping") def play(self): print(f"{s [instruction] | Create a class called Cat to represent a type of pet. [input] |
[output] | def check_sum(array, n): """ Given an array of integers, returns True if the sum of any two of them equals the given parameter 'n'. """ for i in range(len(array)): for j in range(i + 1, len(array)): if array[i] + array[j] == n: return True ret [instruction] | Given an array of integers, write a function to check if the sum of any two of them equals the given parameter ‘n’. [input] | array = [2, 4, 6, 8] n = 10
[output] | import hashlib def sha256_calc(string): """ Calculate SHA256 checksum in Python. """ sha_signature = hashlib.sha256(string.encode()).hexdigest() return sha_signature [instruction] | Using the provided input, calculate the SHA256 checksum in Python. [input] | string = "Hello World!"
[output] | def print_all_primes(n): """ Print all the prime numbers in the range of 2 to n. """ for num in range(2, n+1): if all(num % i != 0 for i in range(2, num)): print(num) [instruction] | Print all the prime numbers in the range of 2 to n. [input] | n = 10
[output] | def split_to_words(string): """ Split a string into its individual words and store it in a list. """ return string.split() [instruction] | Split a string into its individual words and store it in a list. [input] | string = "Hello world, this is a test string."
[output] | To be an AI engineer, at a minimum, a person must have a bachelor’s degree in computer science, mathematics, or a related field. It is also beneficial for a person to have an understanding of artificial intelligence and machine learning principles, and to be familiar with programming languages, such [instruction] | What is the minimum requirements to become an AI Engineer? [input] |
[output] | The data type of the statement is a float. [instruction] | What data type is the following statement? [input] | float score = 73.2
[output] | The square of 5 is 25. [instruction] | Print the square of 5? [input] |
[output] | The following code can be used to create a web crawler that extracts data from a specific website: import requests from bs4 import BeautifulSoup def crawler(url): response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') return soup crawl = crawler('https://ex [instruction] | Write a web crawler for a specific website. [input] |
[output] | let array = [{ id: 1, name: 'Fred'}, {id: 2, name: 'Terry'}, {id: 3, name: 'Marc'}] [instruction] | Edit the following JavaScript code to add a new object to an array [input] | let array = [{ id: 1, name: 'Fred'}, {id: 2, name: 'Terry'}]
[output] | SELECT * FROM product ORDER BY product ASC; [instruction] | Modify the following MySQL query to order the results in ascending order [input] | SELECT * FROM product;
[output] | require "time" module TimeNow def self.display_time puts Time.now end end TimeNow.display_time [instruction] | Write a gem in Ruby to display the current time [input] |
[output] | SELECT * FROM users; [instruction] | Generate a SQL query to retrieve all users [input] |
[output] | Let us consider buying and selling 1 share of the stock 1. Initialize the local maximum profit = 0 and the minimum element = 9 2. Run a loop from i=1 to n and update the local maximum profit and the minimum element as you iterate 3. For each iteration i, check the profit obtained by selling the s [instruction] | Design an algorithm to calculate the maximum profit for buying/selling 1 share of a company's stock. [input] | Share Prices = [9, 11, 8, 5, 7, 10]
[output] | class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __str__(self): return f"This is a rectangle with width of {self.width} and height of {self.height}." [instruction] | In Python, define a class for a rectangle object. [input] |
[output] | for i in range(2, len(array)): print(array[i]) [instruction] | Construct a for loop to traverse an array of integers starting from the third element and ending at the last element. [input] | array = [1,2,3,4,5]
[output] | apple, banana, cherry [instruction] | Output the lexicographical order of a given array of strings. [input] | words = ["apple", "banana", "cherry"]
[output] | The filter() function in Python takes a function and an iterable as input arguments. The filter() function filters out elements from the given iterable (for example, a list) that don't satisfy the given condition determined by the function. It returns an iterator containing the filtered elements. Sy [instruction] | How do you use the built-in function filter() in Python? [input] |