[output] | import random def generate_list(): random_list = [] for i in range(10): random_list.append(random.randint(0, 20)) return random_list [instruction] | Generate a random list containing 10 elements in the range of 0-20 [input] |
[output] | def sort_list(arr): for i in range(len(arr) - 1): min_index = i for j in range(i + 1, len(arr)): if arr[j] < arr[min_index]: min_index = j if min_index != i: arr[i], arr[min_index] = arr[min_index], arr[i] return arr [instruction] | Create a sorting algorithm to sort a given list of numbers from lowest to highest. [input] | [1, 4, 3, 7, 8, 10]
[output] | <?php $str = 'Quick brown fox'; echo ucwords($str); ?> [instruction] | Write code in PHP for capitalizing the first letter of each word in a given string. [input] | Quick brown fox
[output] | bool check = true; string s = "A quick brown fox jumps over the lazy dog"; string alphabet = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < alphabet.length(); i++) { if (!s.contains(alphabet.charAt(i)+"")) { check = false; break; } } if (check) { System.out.println(" [instruction] | Check if a given string contains all the alphabets. [input] | A quick brown fox jumps over the lazy dog
[output] | #include <stdio.h> int main() { char op; float num1, num2; printf("Enter the operator (+, -, *, /): "); scanf("%c", &op); printf("Enter two operands: "); scanf("%f%f",&num1, &num2); switch (op) { case '+': printf("%.1f + %.1f = %.1f", num1, [instruction] | Design a C program to create a calculator. [input] |
[output] | var min = 10; var max = 35; var randomNumber = Math.random() * (max - min) + min; console.log(randomNumber); [instruction] | Generate a random number between 10 and 35 in JavaScript. [input] |
[output] | SELECT COUNT(gender) FROM student WHERE gender = 'female'; [instruction] | Write a query in MySQL to find the total count of items in a particular column. [input] | TABLE student { id INT, name VARCHAR(100), age INT, gender VARCHAR(10) }
[output] | db.students.find({ marks_arr : { $in : [100] } }) [instruction] | Design a query in MongoDB to select documents based on a particular value in an array. [input] | DB student { id INT, name VARCHAR(100), marks_arr INT[], total INT }
[output] | def tree_traversal(root): if root is None: return # First print the data of node print(root.data) # Then recur on left child tree_traversal(root.left) # Finally recur on right child tree_traversal(root.right) [instruction] | Find a tree traversal algorithm in Python. [input] |
[output] | if userID > 0: print("Welcome new user") else: print("User ID is invalid") [instruction] | Construct an if/else statement in Python to print "Welcome new user" if the value of variable "userID" is greater than 0. [input] | userID = 5
[output] | <div class="message"></div> [instruction] | Using CSS, create a div element with a class name of message. [input] |
[output] | <canvas id="myCanvas" width="500" height="250"></canvas> [instruction] | Using HTML5, create a canvas element with a width of 500px and a height of 250px. [input] |
[output] | The command for executing a code written in Java is "java [filename]". [instruction] | What is the command for executing a code written in Java? [input] |
[output] | The command to create an array in Java is "int[ ] arr = new int[size]". [instruction] | What is the command to create an array in Java? [input] |
[output] | The command to create a new branch in Git is "git branch [name]". [instruction] | Write a command to create a new branch in Git. [input] |
[output] | Python uses dynamic typing, meaning that the type of data in a variable is not explicitly declared, instead it is automatically determined by the interpreter when a value is assigned to a variable. This allows for data types to be changed throughout the course of a program. [instruction] | How does Python handle data types? [input] |
[output] | In JavaScript, you can remove an item from an array using the "splice()" method. The method takes two parameters, the first is the index of the element to be removed and the second parameter is the number of elements to be removed. [instruction] | How do you remove an item from an array in JavaScript? [input] |
[output] | #include <algorithm> #include <vector> using namespace std; int main() { vector<int> v = {3, 1, 5, 4, 7, 2}; sort(v.begin(), v.end()); return 0; } [instruction] | Write a C++ code to create a vector of integers and then sort them in increasing order. [input] | vector<int> v = {3, 1, 5, 4, 7, 2};
[output] | $my_array = array('apple', 'orange', 'banana'); [instruction] | Rewrite the following PHP code to add a new item to the array. [input] | $my_array = array('apple', 'orange');
[output] | let result = num1 + num2; return result; // 12 [instruction] | Write a JavaScript code to calculate the sum of two numbers and return the result. [input] | num1 = 5; num2 = 7;
[output] | UPDATE employees SET salary = 50000 WHERE title = 'Manager'; [instruction] | Write an SQL query to update the salary of all employees with the title 'Manager' to $50000. [input] |
[output] | function reverseArray(input) { let result = []; for (let i = input.length - 1; i >= 0; i--) { result.push(input[i]); } return result; } [instruction] | Write code to create a function in JavaScript to reverse a given array. [input] | var input = [1, 2, 3, 4, 5];
[output] | num += 64 letter = num.chr puts letter # Output: '8' [instruction] | How will you modify the following Ruby code to convert a given number to its corresponding alphabetical letter? [input] | num = 56
[output] | <a href="https://example.com">example.com</a> [instruction] | Generate a correct HTML anchor tag for a link to "example.com" [input] |
[output] | public static double calculateStandardDeviation(List<Integer> list) { double mean = computeMean(list); double temp = 0; for(double num: list) temp += (num-mean)*(num-mean); double variance = temp/list.size(); double standardDeviation = Math.sqrt(variance); return [instruction] | Design a function to calculate the standard deviation of a set of data [input] | [2, 4, 1, 6, 8]
[output] | p { font-size: 16px; } [instruction] | Generate a CSS code to set the font size of all <p> tags. [input] |
[output] | def sum_of_squares(n): result = 0 for i in range(1, n + 1): result += i**2 return result [instruction] | Write a function in Python that takes a number n as its parameter and returns the sum of the squares of the first n natural numbers [input] |
[output] | .large-margin { margin-top: 10px; margin-bottom: 10px; } [instruction] | Using CSS, create a class called "large-margin" which sets top and bottom margins of 10 pixels. [input] |
[output] | array[2] //3 [instruction] | Access the 3rd element in a JSON Array [input] | [1, 2, 3, 4, 5]
[output] | $(document).ready(function(){ setTimeout(function(){ $("#element").hide(); }, 3000); }); [instruction] | Write a JQuery function that hides an element after 3 seconds. [input] |