[output] | int arr[N][M] = {0}; [instruction] | Initialize a 2D array with all elements set to 0 in C. [input] |
[output] | Area = 4 x 4 = 16 [instruction] | Calculate the area of a square with side length 4. [input] |
[output] | import React from 'react'; const HelloWorld = () => ( <h1>Hello World!</h1> ); export default HelloWorld; [instruction] | Create a React component that displays the text "Hello World!". [input] |
[output] | 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 [instruction] | Generate a Fibonacci sequence up until 50. [input] |
[output] | Odd [instruction] | What is the output of the following code? def check_even(num): if num % 2 == 0: return "Even" else: return "Odd" print(check_even(3)) [input] |
[output] | <h1><strong>Heading 1</strong></h1> <h2><strong>Heading 2</strong></h2> [instruction] | Edit the following HTML code to make all the headings bold. <h1>Heading 1</h1> <h2>Heading 2</h2> [input] |
[output] | Three popular JavaScript frameworks are React, Angular, and Vue. [instruction] | Name 3 popular JavaScript frameworks. [input] |
[output] | The best practices for writing JavaScript code include using valid and properly formatted code, utilizing functions, avoiding global variables, using comments to explain code, using object and array literals, and avoiding memory leaks. [instruction] | What are the best practices when writing Javascript code? [input] |
[output] | correct [instruction] | Classify the given code as "correct" or "incorrect". [input] | def extract_file_name(file_path): dot_index = file_path.find('.') slash_index = file_path.find('/')
[output] | verdict = "Adult" if age > 18 else "Minor" [instruction] | Convert the following code from if/else to a ternary operator and output the result as a string. [input] | if age > 18: verdict = "Adult" else: verdict = "Minor"
[output] | my_dict = { "apple": True, "banana": True, "strawberry": True } [instruction] | Take the input list and transform it to a dictionary where the keys are the elements of the list and the values equal to True. [input] | my_list = ["apple", "banana", "strawberry"]
[output] | 45 [instruction] | Output the sum of all the elements in the two-dimensional array. [input] | arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[output] | def concat_strings(string1, string2): return string1 + string2 [instruction] | Create a function that takes two strings as inputs and outputs their concatenation. [input] |
[output] | a, b = b, a [instruction] | Change the code so that it swaps the contents of two variables in one line. [input] | a = 5 b = 10
[output] | True [instruction] | Detect if the given code is a loop or not and output true if it is a loop or false if it is not. [input] | x = 0 while (x < 10): x += 1
[output] | number = int(input("Enter a number: ")) print("You entered: ", number) [instruction] | prompt the user to enter a number, then output it in a sentence [input] |
[output] | # calculate the area of a triangle # define the constant base and height base = 6.0 height = 4.5 # calculate the area area = 0.5 * base * height # print the result print('The area of the triangle is: %0.2f cm^2' %area) [instruction] | Use the following input to write a python code for calculating the area of a triangle [input] | Base = 6cm, Height = 4.5cm
[output] | int number; Scanner in = new Scanner (System.in); do { number = in.nextInt (); } while (number <= 0); [instruction] | Cut and paste the following Java code snippet and add a condition to ensure that the number entered is always greater than 0. [input] | int number; Scanner in = new Scanner (System.in); number = in.nextInt ();
[output] | string s = " "; s = s.replaceAll("abcd", ""); [instruction] | Using the given input, modify the code to remove all occurences of "abcd" [input] | string s = "abcd abcd abcd abcd";
[output] | A reduction function is needed in order to solve the given problem, which will iterate through the list of numbers and compute the average age. The function could take the form of a loop or other type of iterator. [instruction] | What type of function is needed to solve the following problem [input] | Compute the average age of a given list of numbers
[output] | The component in question is known as the Central Processing Unit (CPU). [instruction] | What is the name of the following component of a computer system [input] | A component that can perform data processing and calculations
[output] | # function to do binary search def binarySearch(array, x): l, r = 0, len(array)-1 while l <= r: mid = l + (r - l)//2; # Check if x is present at mid if array[mid] == x: return mid # If x is greater, ignore left half [instruction] | Implement Binary Search in Python [input] | [2, 3, 4, 5, 11, 19, 20]
[output] | <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ul> [instruction] | Using the given input, modify the following HTML code so it shows a list of 5 items [input] | <ul> <li></li> </ul>
[output] | SELECT Address FROM Users; [instruction] | Generate a valid MySQL query to retrieve a column from a table [input] | Table = Users, Column = Address
[output] | //function to split a string into an array function stringToArray(s) { return s.split(' '); } //create a string s = "hello world"; //convert string to array array = stringToArray(s); //print the array console.log(array); [instruction] | Generate a correct JavaScript program to convert a string into an array [input] | s = "hello world";
[output] | x = 5 print("x out of " + str(x)) [instruction] | Using the comment as a guide, edit the code that prints "X out of 10" to print "X out of Y". [input] | x = 5 print("x out of 10") #TODO: replace 10 with the correct variable
[output] | int xor(int x, int y) { return (x || y) && !(x && y); } [instruction] | Generate an XOR function in C++. [input] |
[output] | def add(x, y): """Return the sum of x and y.""" return x + y [instruction] | Create a function in Python that adds two numbers. [input] |
[output] | <!DOCTYPE html> <html> <head> <title>User Ages</title> </head> <body> <ul> <li>Alice: 25</li> <li>Bob: 27</li> <li>Carol: 30</li> </ul> </body> </html> [instruction] | Create an HTML page that displays a list of users and their ages. [input] | Alice: 25 Bob: 27 Carol: 30
[output] | public static int largestNumber(int[] arr) { int max = arr[0]; for (int i = 1; i < arr.length; i++) if (arr[i] > max) max = arr[i]; return max; } [instruction] | Generate a function in Java for finding the largest number in an array. [input] |