[output] | 3 [instruction] | Find the index of the string "the" in the sentence "I saw the cat". [input] |
[output] | my_set = {3, 6, 9} [instruction] | Create a set containing the numbers from 1-10 that are divisible by 3. [input] |
[output] | 3132 [instruction] | Calculate the product of the numbers 87 and 36. [input] |
[output] | def ascending_order(word): list = [] for letter in word: list.append(letter) sorted_list = sorted(list) return "".join(sorted_list) [instruction] | Create a function in python that takes a string and returns a new string with the same letter count but in ascending order [input] | word = “tweet”
[output] | let max; if (num1 > num2) { max = num1; } else { max = num2; } if (max < num3) { max = num3; } [instruction] | Create a basic JavaScript code to input three numbers and store the largest one in a variable. [input] | num1 = 10 num2 = 20 num3 = 30
[output] | def replace_zeros(input_list): output_list = [x if x != 0 else 1 for x in input_list] return output_list [instruction] | Generate a shorthand method in Python to replace all 0s with 1. [input] | input_list = [1, 0, 1, 0, 0]
[output] | def dict_sort(list_dict): sorted_dict = sorted(list_dict, key = lambda x: x['age']) return sorted_dict [instruction] | Generate a method in Python to sort a given list of dictionaries. [input] | list_dict = [{'name': 'a', 'age': 23}, {'name': 'b', 'age': 19}, {'name': 'c','age': 36}]
[output] | function reverseString(text) { return text.split("").reverse().join(""); } console.log(reverseString(text)); [instruction] | Write a simple script in JavaScript to reverse a string. [input] | text = “hello world”
[output] | def sumList(list): sum = 0 for i in list: sum = sum + i return sum print(sumList(list)) [instruction] | Modify the given Python code to calculate the sum of the given list and print the output. [input] | list = [1,2,3,4,5]
[output] | function findGCD(x, y) { if (x === 0) return y; if (y === 0) return x; if (x === y) return x; if (x > y) return findGCD(x - y, y); return findGCD(x, y - x); } console.log(findGCD(x, y)); [instruction] | Compose a script in JavaScript for finding the greatest common divisor of two numbers. [input] | x = 36; y = 60;
[output] | SELECT c.customer_id, c.name FROM customers AS c INNER JOIN orders AS o ON c.customer_id = o.customer_id; [instruction] | Write a SQL statement that finds all customers who have placed orders [input] |
[output] | 100 [instruction] | What is the value of the math expression 100(log_10 10) [input] |
[output] | model = tf.keras.Sequential([ tf.keras.layers.Dense(10, activation='relu', input_shape=(5,)), tf.keras.layers.Dense(2, activation='softmax'), ]) [instruction] | Create a neural network with 5 inputs and 2 outputs [input] |
[output] | 13 [instruction] | Sum up the elements of this array [input] | [2,7,1,3]
[output] | // loop through all n elements in the array for (int i = 0; i < n; i++) { // code } [instruction] | Add a comment to this code [input] | for(int i = 0; i < n; i++)
[output] | public class MyClass { public static void main(String[] args) { System.out.println("Hello World!"); } } [instruction] | Write a simple Java class [input] |
[output] | 41 [instruction] | Output the largest number in this array [input] | [20, 6, 36, 41, 12, 3]
[output] | public static boolean isSubstring(String s1, String s2){ int len1 = s1.length(); int len2 = s2.length(); if(len1 < len2){ if(s2.contains(s1)){ return true; } }else{ if(s1.contains(s2)){ return true; [instruction] | Create a function that takes two String as parameters and return true if one String is substring of the other [input] |
[output] | <script> setTimeout(function(){ alert("Hello World!"); }, 2000); </script> [instruction] | Edit this code to show a message after 2 seconds [input] | <script> alert("Hello World!"); </script>
[output] | def permute(nums): # base case when only one element in the list if len(nums) == 1: return [nums] permutations = [] for i in range(len(nums)): m = nums[i] # extract remaining list remain = nums[:i] + nums[i+1:] # Iterate over remai [instruction] | Write a function to find all distinct permutations of a given list [input] | [1,2,3]
[output] | def delete_duplicates(string): letters = set() newstring = "" for char in string: if char in letters: continue else: letters.add(char) newstring += char return newstring [instruction] | Construct an algorithm to delete duplicate characters from a string [input] |
[output] | myName = "John Doe" [instruction] | Create a variable called myName and assign your name to it. [input] |
[output] | The standard indentation size for Python code is 4 spaces. [instruction] | What is the standard indentation size for Python code? [input] |
[output] | for i in range(0, 11): if i%2 == 0: print(i) [instruction] | Write a code to print out all the even numbers in the range 0 to 10. [input] |
[output] | my_dict = {'apple': 'fruit', 'carrot': 'vegetable', 'house': 'structure', 'dog': 'animal'} [instruction] | Create a dictionary and assign four key-value pairs. [input] |
[output] | my_array = ["John", "Paul", "George", "Ringo"] [instruction] | Create an array and assign four elements to it. [input] |
[output] | if x > 0: # execute one block of code else: # execute another block of code [instruction] | Construct an if-else statement to handle a conditional execution. [input] | if x is greater than 0
[output] | i = 1 while i <= 10: print(i) i += 1 [instruction] | Create a while loop that prints the numbers 1-10 [input] |
[output] | for i in range(1, 5): for j in range(0, i): print("*", end="") print() # add a new line [instruction] | Construct a for loop to print a user-defined pattern. [input] | * ** *** ****
[output] | import numpy as np # Convert to numpy array arr = np.array([3, 5, 1, 9, 6]) # Sort the array arr.sort() # Print the sorted array print(arr) [instruction] | Convert this list into a numpy array and sort it. [input] | [3, 5, 1, 9, 6]