[output] | The expression 3 + 4 * 5 will evaluate to 23, which is a number data type. [instruction] | What data type should the following expression evaluate to? [input] | 3 + 4 * 5
[output] | #Process a given array and add 10 to each value arr = [1, 2, 3, 4, 5] #Loop through the array for i in range(len(arr)): #Add 10 to the current element arr[i] = arr[i] + 10 #Print the modified array print(arr) """ Output: [11, 12, 13, 14, 15] """ [instruction] | Write a code to process a given array and add 10 to each value stored in the array. [input] | arr = [1, 2, 3, 4, 5]
[output] | #Format a given date date = '2020-10-25' #Split the date month, day, year = date.split('-') #Format the date formatted_date = month + ' ' + day + ', ' + year #Print the formatted date print(formatted_date) """ Output: October 25, 2020 """ [instruction] | Format a given date in the following format: "Month Day, Year" [input] | date = '2020-10-25'
[output] | You can check if a given key exists in a dictionary using the `in` keyword. For example: my_dict = { 'name': 'John', 'age': 20 } if 'name' in my_dict: print('Key found') [instruction] | How can you check if a given key exists in a dictionary? [input] |
[output] | lst = [] for i in range(m, n+1): lst.append(i) [instruction] | Construct a list of integers from m to n. [input] | m = 3 n = 8
[output] | The greatest common divisor (GCD) of 24 and 32 is 8. [instruction] | Find the greatest common divisor (GCD) of 24 and 32. [input] |
[output] | def compare(object1, object2): if object1 == object2: return 0 elif object1 < object2: return -1 else: return 1 [instruction] | Compare two objects and return 0 if they are equal, -1 if the first is less than the second, and 1 if the first is greater than the second. [input] | object1 = 7 object2 = 8
[output] | pattern = r"\b[^a]*a[^a]*\b" [instruction] | Write a regular expression to match only words containing a single 'a' character. [input] |
[output] | text = "We Are Learning Natural Language Processing" [instruction] | Capitalize the letters A - Z in the given string. [input] | text = "We are learning natural language processing"
[output] | #include<iostream> using namespace std; int sumArray(int arr[], int size) { int sum = 0; for (int i=0; i<size; i++) sum += arr[i]; return sum; } int main() { int arr[] = {1, 2, 3, 4, 5}; int size = sizeof(arr) / sizeof(arr[0]); cout << "Sum of array elements: " << sumArray(arr, siz [instruction] | Generate a C++ program to sum up the elements of an array [input] |
[output] | Exponential function. [instruction] | Identify the type of a given function [input] | f(x)=2^x
[output] | \b[1-9][0-9]* [instruction] | Write a Regex expression to extract all numbers larger than 0 in a string [input] |
[output] | <html> <head> <title>Welcome</title> </head> <body> <h1>Welcome</h1> <p>Hello World!</p> </body> </html> [instruction] | Generate a HTML code to display a basic webpage with [input] | Heading: Welcome Text: Hello World!
[output] | dataType variableName; [instruction] | Identify the correct syntax to declare a variable in Java [input] |
[output] | * { color: #7a00e6; } [instruction] | Construct a CSS style sheet [input] | Change the default color of the HTML text to be purple
[output] | for i in range(51): print(i) [instruction] | Construct a for loop to print the integer from 0 to 50. [input] |
[output] | True [instruction] | Which boolean value will be returned if the expression 5 is not equal to 10 is evaluated? [input] |
[output] | Two, 2. [instruction] | How many parameters does the following function require? [input] | def multiply(a, b): return a * b
[output] | list = [1, 2, 'y', 'y', 1] [instruction] | Replace all the x in the given list with y. [input] | list = [1, 2, 'x', 'x', 1]
[output] | list_keys = list(my_dict.keys()) print(list_keys) Output: ['Name', 'Age', 'City'] [instruction] | Generate a list of dictionary keys from the given dictionary. [input] | my_dict = {'Name':'John','Age':24,'City':'New York'}
[output] | numbers = [x for x in range(21) if x % 3 == 0] [instruction] | Make a list of numbers from 0 to 20 that are divisible by 3. [input] |
[output] | import random def random_hex_colour_code(): return '#' + ''.join([random.choice('0123456789ABCDEF') for x in range(6)]) print ("Random Hex Color Code:", random_hex_colour_code()) [instruction] | Generate a random hex color in Python. [input] |
[output] | <html> <head> </head> <style> #container{ width: 100%; display: flex; } #left-container{ width: 20%; } #right-containers{ width: 80%; display: flex; } #right-container1 [instruction] | Create an HTML page with a layout consisting of 3 containers: one on the left and two on the right. [input] |
[output] | def is_prime?(number) if number < 2 return false else (2...number).each do |i| if number % i == 0 return false end end true end end [instruction] | Create an if statement in Ruby that checks if a given number is a prime number. [input] |
[output] | public class Triangle { public static void main(String[] args) { int limit=15; System.out.println("Right Angle Triangle"); for (int i = 0; i < limit; i++) { for (int j = 0; j <= i; j++) { System.out.print("*"); [instruction] | Output a triangle shape using only asterisks (e.g. *) in Java. [input] |
[output] | foreach ($arr as $key => $value) { echo "Key=" . $key . ", Value=" . $value; echo "\n"; } [instruction] | Create a loop in PHP to iterate over an associative array and print each key and value. [input] | $arr = ["a" => 1, "b" => 2, "c" => 3];
[output] | def calculate_mean(numbers): total_sum = 0; for num in numbers: total_sum += num mean_average = total_sum / len(numbers) return mean_average [instruction] | Write a function in Python that takes a list of integers as an argument and calculates the mean average. [input] |
[output] | public static void printDescendingOrder(int[] arr) { // sort the array in descending order Arrays.sort(arr, Collections.reverseOrder()); for (int i=0; i<arr.length; i++) System.out.print(arr[i] + " "); } [instruction] | Output all items from an array in descending order in Java. [input] |
[output] | let result = []; let prev = 0; let next = 1; while (next < 10) { temp = prev; prev = next; next = temp + next; result.push(next); } console.log(result); [instruction] | Create a while loop in JavaScript to print the Fibonacci series. [input] |
[output] | def split_string(string): return string.split() [instruction] | Write a function in Python to split a given string into the words in the string. [input] |