[output] | [instruction] | Print the element with the second greatest value from an array named 'numbers'. [input] | numbers = [10, 5, 15, 20, 25]
[output] | def reverse_list(lst): rev_lst = lst[::-1] return rev_lst [instruction] | Write an algorithm to reverse a lis [input] | [1,2,3,4,5]
[output] | string = "Hello World" string = string.upper() print(string) [instruction] | Modify the following code to turn all the words in a sentence to upper case [input] | string = "Hello World"
[output] | def find_sublist(lst): total_sum = sum(lst) half = total_sum//2 taken = [False]*len(lst) curr_sum = lst[0] taken[0] = True idx = 0 flag = False for i in range(1, len(lst)): if curr_sum < half: taken[i] = True curr_sum += lst[i] [instruction] | Write an algorithm to split a given list into two sublists with equal sums [input] | [1, 4, 2, 5, 3]
[output] | difference_list = [1, 2, 6] [instruction] | Given two lists, create a list that contains the difference. [input] | list1 = [1, 2, 3, 4, 5] list2 = [3, 4, 5, 6]
[output] | ABCD-*+ [instruction] | Convert the given expression from infix notation to postfix notation. [input] | A + B * (C - D)
[output] | The easiest way to generate a random number between 0 and 10 in JavaScript is to use the Math.random() function. For example, the following example will generate a random number between 0 and 10 (inclusive): Math.random() * 10 [instruction] | How do you generate a random number between 0 and 10 in JavaScript? [input] |
[output] | Create a Flask application with a route to accept an email address and the notification message. Use the Flask-Mail extension to send an email containing the notification message to the provided email address. [instruction] | Create a Flask application to send an email notification. [input] |
[output] | try: list1 = [1, 2, 3] print(list1[5]) except IndexError: print("IndexError occurred.") [instruction] | Add a try-except clause to the given code to catch IndexError exceptions. [input] | list1 = [1, 2, 3] print(list1[5])
[output] | class Set: def __init__(self): self.elements = [] def add(self, element): if element not in self.elements: self.elements.append(element) def remove(self, element): if element in self.elements: self.elements.remove(element) [instruction] | Create a class that implements a set data structure. [input] |
[output] | The new list is [4]. [instruction] | Delete the odd elements in a given list. [input] | list4 = [3, 7, 4, 5]
[output] | The two arrays are not equal. [instruction] | Determine whether two given arrays are equal or not. [input] | arr1 = [1, 2, 3] arr2 = [1, 2, 4]
[output] | The new string is "HelloWorld". [instruction] | Given two strings, create a new string that is their concatenation. [input] | string1 = "Hello" string2 = "World"
[output] | module F(A,B,C,D,Z); input A, B, C, D; output Z; reg Z; always @ (A,B,C,D) begin Z = ~(A | ~B | C | ~D); end endmodule [instruction] | Generate a valid RTL(Register Transfer Level) design in Verilog to implement the following Boolean function [input] | F(A,B,C,D) = (A + !B + C + !D)'
[output] | Storytelling [instruction] | classify the following text into its respective category [input] | Once upon a time, there was a young prince who lived in a castle
[output] | LIBRARY ieee; USE ieee.std_logic_1164.all; entity Multiplexer is Port ( a,b,c,d: in std_logic; sel: in std_logic; y : out std_logic); end Multiplexer; architecture Behavioral of Multiplexer is begin process(a,b,c,d,sel) begin if sel = '0' then [instruction] | Generate a valid VHDL code for given design [input] | Implement a 4-to-1 multiplexer using the given data ports
[output] | import networkx as nx G = nx.DiGraph() G.add_nodes_from([1,2,3,4,5]) G.add_edge(1,4,weight=4) G.add_edge(1,2,weight=7) G.add_edge(1,3,weight=2) G.add_edge(2,3,weight=6) G.add_edge(2,5,weight=5) G.add_edge(3,4,weight=3) G.add_edge(3,5,weight=2) G.add_edge(4,5,weight=2) start = 1 end = 5 shortest [instruction] | Find the shortest path between two nodes using Dijkstra's algorithm [input] | A graph with 5 nodes and 7 edges
[output] | x = 0 while x!=10: x=x+1 [instruction] | Rewrite the code snippet to avoid the use of goto statement [input] | start: x=x+1 if x==10 goto start
[output] | A callback is a function that is passed as an argument to another function and is executed when the callback function completes its task. A promise is an object that can be returned synchronously from an asynchronous function. It acts as a placeholder for the eventual result of the asynchronous func [instruction] | What is the difference between a Node.js callback and a promise? [input] |
[output] | { "url": "example.com/api", "method": "POST", "data": { "username": "example", "password": "example" } } [instruction] | Provide a JSON object with the structure required to make an API call using Axios. [input] |
[output] | <form> <label for="fname">First Name: </label> <input type="text" name="fname" id="fname"><br><br> <label for="lname">Last Name: </label> <input type="text" name="lname" id="lname"><br><br> <input type="submit" value="Submit"> </form> [instruction] | Write an HTML form that collects first name and last name. [input] |
[output] | def generateId(string): hashValue = hash(string) id = 0 while hashValue > 0: id += hashValue % 10 hashValue //= 10 return id [instruction] | Write a function that generates a unique integer ID given a string input. [input] |
[output] | def classify(sentence): if 'sports' in sentence.lower(): return 'sports' elif 'entertainment' in sentence.lower(): return 'entertainment' elif 'politics' in sentence.lower(): return 'politics' elif 'finance' in sentence.lower(): return 'finance' el [instruction] | You need to classify a given sentence into one of 5 categories. [input] | This sentence is about sports
[output] | def sortByLength(sentence): words = sentence.split(' ') sortedWords = sorted(words, key=len) return sortedWords [instruction] | You need to find all the words in a given sentence sorted by their length. [input] | I like to read books
[output] | def rearrange(string): seen = set() result = [] for char in string: if char not in seen: seen.add(char) result.append(char) else: for ch in string: if ch not in seen: seen.add(ch) [instruction] | You need to rearrange the characters in a given string such that no two same characters are adjacent to each other. [input] | abccab
[output] | def codeEditor(): # Initialize the editor editor = texteditor.Editor() # Create buttons for search, replace, undo and redo searchButton = texteditor.Button(caption="Search", onclick=editor.search) replaceButton = texteditor.Button(caption="Replace", onclick=editor.replace) [instruction] | You need to build a code editor with basic features like search, replace, undo, and redo. [input] |
[output] | def add(a, b): sum = a + b return sum [instruction] | Build a system that takes in two numbers and outputs the summation of the two numbers. [input] | 2, 3
[output] | def diff(a, b): aSet = set(a) bSet = set(b) diffSet = aSet.difference(bSet) return ''.join(diffSet) [instruction] | Take two text strings as input and output the difference between two strings. [input] | This is a text string, That is a text string
[output] | import random def randomString(): letters = 'abcdefghijklmnopqrstuvwxyz' result = [] for _ in range(100): letter = random.choice(letters) result.append(letter) return ''.join(result) [instruction] | Generate a random string with length 100 consisting of lowercase letters. [input] |
[output] | def traverseTree(node): result = [] if node is None: return [] else: result.append(node.data) result += traverseTree(node.left) result += traverseTree(node.right) return result [instruction] | You need to build a function that take a given tree and returns a list containing the data stored at each level. [input] | 1 / \ 2 3 / \ / 4 5 6