[output] | import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class App { // Function to calculate the area of triangle public static double calculateArea(int a, int b, int c) { double s = (a + b + c) / 2; double area = Math.s [instruction] | Create a Spring boot program to find the area of a triangle. [input] |
[output] | <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Title of the document</title> </head> <body> <table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> [instruction] | You need to generate an HTML table and style it with CSS. [input] | table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; }
[output] | false [instruction] | for the given array, output true if the array does not contain duplicates,output false if it contains any. [input] | arr = [1, 3, 5, 6, 1]
[output] | def decrypt(enc_string): s = 0 decrypted = '' for i in range(len(enc_string)): s += ord(enc_string[i]) decrypted += chr(s) return decrypted [instruction] | Create a function to decrypt an encrypted string. [input] |
[output] | common_elements = [2, 5, 9] [instruction] | Given two sorted arrays, find elements that exist in both arrays. [input] | arr1 = [1, 2, 5, 8, 9, 10] arr2 = [2, 5, 6, 9]
[output] | import random def random_numbers(): for _ in range(10): num = random.randint(1, 10) print(num) random_numbers() [instruction] | Use a random number generator to generate random numbers between 1 and 10. [input] |
[output] | str = "Hello World" [instruction] | Modify this string in such a way that it should start with "Hello " and must end with " World". [input] | str = "World, say hello"
[output] | answer = 8 [instruction] | Recalculate this code block with the new input given and provide the new output. [input] | a = '1' b = 2 answer = int(a) + int(b) New input: a = 5 b = 3
[output] | SELECT * FROM records WHERE age>25 and address like 'Mumbai%'; [instruction] | Write SQL query to get the records with age>25 and address in Mumbai. [input] |
[output] | const divisibleBy4 = (num) => { if (num % 4 === 0) return true; else return false; }; [instruction] | Create a JavaScript function to check if a number is divisible by 4. [input] |
[output] | block { position: absolute; top: 0; left: 50%; transform: translateX(-50%); } [instruction] | Write CSS code to position a block at the top centre of the page. [input] |
[output] | let count = 0; const keyObject = () => { let newObj = {[`key_${count}`]: count}; count++; return newObj; } [instruction] | Write code to create an object with the key which will be incremented on every call of the code. [input] |
[output] | NLTK (Natural Language Toolkit) is a popular library used for text processing and breaking it down into basic meaningful parts. It is a platform for building Python programs to work with human language data. [instruction] | Name a popular library used to break down text into basic meaningful parts. [input] |
[output] | function checkEven(number) if number modulo 2 = 0 return true else return false end function [instruction] | Re-write this algorithm in pseudo-code. [input] | def checkEven(number): if(number % 2 == 0): return True else: return False
[output] | overflow-y: hidden; [instruction] | Create a CSS property to remove the vertical scrollbar. [input] |
[output] | list_of_strings = ['hello', 'world', 'foobar'] for string in list_of_strings: print(len(string)) [instruction] | Print out the length of each string in the list. [input] | list_of_strings = ['hello', 'world', 'foobar']
[output] | nums = [1, 2, 3, 4] new_nums = [num*10 for num in nums] print(new_nums) [instruction] | Create a new list of elements, multiplied by 10. [input] | nums = [1, 2, 3, 4]
[output] | arr = [3, 9, 8, 1, 6, 4] new_arr = [num for num in arr if num > 5] print(new_arr) [instruction] | Generate a new array and store only elements that are greater than 5. [input] | arr = [3, 9, 8, 1, 6, 4]
[output] | arr = [1, 3, 5, 6, 8] arr[2], arr[4] = arr[4], arr[2] print(arr) [instruction] | Swap the elements at index 2 and 4. [input] | arr = [1, 3, 5, 6, 8]
[output] | list_of_strings = ['I', 'am', 'a', 'string'] concat = ' '.join(list_of_strings) print(concat) [instruction] | Concatenate the elements of the list into a string. [input] | list_of_strings = ['I', 'am', 'a', 'string']
[output] | list_of_strings = ['stack', 'super', 'stone', 'sit'] words_start_s = [word for word in list_of_strings if word.startswith('s')] print(words_start_s) [instruction] | Extract all the words that begin with 's' from the given list. [input] | list_of_strings = ['stack', 'super', 'stone', 'sit']
[output] | arr = [1, 2, 3, 4, 5] arr.reverse() print(arr) [instruction] | Reverse a given array's elements and print the resulting array. [input] | arr = [1, 2, 3, 4, 5]
[output] | arr = [3, 5, 7, 9, 1] new_arr = [num if num % 2 == 0 else 0 for num in arr] print(new_arr) [instruction] | Create a new array from the given array by replacing all the odd numbers with 0. [input] | arr = [3, 5, 7, 9, 1]
[output] | O(n) [instruction] | Determine the time complexity of the code given below as a function of n. [input] | def foo(A, n): if n == 1: return A[0] else: return foo(A, n - 1) + A[n - 1]
[output] | def add_three(n1, n2, n3): return n1 + n2 + n3 [instruction] | Create a function to add three numbers together [input] |
[output] | def print_message(message): for i in range(3): print(message) [instruction] | Create a function that prints a provided message 3 times [input] | message = "Hello World!"
[output] | A hash table is the most appropriate data structure for fast searches. [instruction] | What data structure is most appropriate for fast searches? [input] |
[output] | def double(number): return number * 2 [instruction] | Fix this indentation error in the following Python code [input] | def double(number): return number * 2
[output] | def are_lists_intersect(list1, list2): # Set pointer to head node temp1 = list1 temp2 = list2 # Get lengths list1_length = 0 list2_length = 0 # Count length for each list while (temp1): list1_length += 1 temp1 = temp1.next while [instruction] | Create code that given two linked lists, determine if they intersect [input] | Two linked lists: list1 = [3, 7, 8, 10] and list2 = [99, 1, 8, 10]
[output] | import json data = { "name": "John Doe", "age": 30 } marshalled_data = json.dumps(data) [instruction] | Edit this code so that it can marshall a json object [input] | import json data = { "name": "John Doe", "age": 30 }