[output] | Software developers should follow coding style guidelines for a few reasons. First and foremost, adherence to coding style is essential for creating code that is easy to read, understand and maintain. Especially when working on a team, consistency in style allows developers to understand each other’ [instruction] | Explain why software developers should follow coding style guidelines. [input] |
[output] | SELECT COUNT(*) from people WHERE age < 25; [instruction] | Write a SQL query to find the number of people below the age of 25 in the table ‘people’. [input] |
[output] | SELECT person, age FROM rdf WHERE type = 'ex:Person' AND predicate = 'ex:age'; [instruction] | Convert the following SPARQL query to a SQL query. [input] | SELECT ?person ?age WHERE { ?person rdf:type ex:Person . ?person ex:age ?age }
[output] | def find_median(arr): arr.sort() if len(arr) % 2 == 0: median = (arr[(len(arr)//2)-1] + arr[len(arr)//2])/2 else: median = arr[len(arr)//2] return median median = find_median([3,7,2,1,9]) print(median) # Prints 3.5 [instruction] | Find the median of the given array [3,7,2,1,9]. [input] |
[output] | let bob = { name: 'Bob', age: 30 }; [instruction] | Create a JavaScript object literal with two properties: a key of name with a value of 'Bob' and a key of age with a value of 30. [input] |
[output] | import xml.etree.ElementTree as ET def xml_builder(data): root = ET.Element('root') for key, value in data.items(): child = ET.SubElement(root, key) if type(value) is dict: for k, v in value.items(): sub_child = ET.SubElement(child, k) [instruction] | Write a code snippet to produce an XML result for a given input data structure. [input] | key1: value1, key2: { key2.1: value2.1, key2.2: value2.2 }
[output] | class HashTable: def __init__(self, size): self.size = size self.table = [None] * size def insert(self, key, value): hash_value = hash(key) index = hash_value%self.size if self.table[index] == None: self.table[index] = [key, value] [instruction] | Create a hashtable in Python of size 8 and insert five elements. [input] |
[output] | function getValue(obj, key) { return obj[key]; } [instruction] | Create a function in JavaScript to get the value of a key from a JSON object. [input] |
[output] | def find_max(arr): max = arr[0] for i in range(1, len(arr)): if arr[i] > max: max = arr[i] return max arr = [7, 9, -2, 15, 3] print(find_max(arr)) [instruction] | Find the maximum value of an array without using any built-in functions [input] | [7, 9, -2, 15, 3]
[output] | def reverseString(str): reversed_str = "" for i in range(len(str)-1, -1, -1): reversed_str += str[i] return reversed_str print(reverseString("Hello World")) [instruction] | Develop an algorithm for reversing a string without using any reverse string methods. [input] | Hello World
[output] | public static List<Integer> removeDuplicates(int[] arr) { List<Integer> uniqueList = new ArrayList<>(); for (int i : arr) { if (!uniqueList.contains(i)) { uniqueList.add(i); } } return uniqueList; } [instruction] | Write a function in Java to delete duplicate elements. [input] |
[output] | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ [instruction] | Create a regex expression that matches all valid IP addresses. [input] |
[output] | UPDATE products SET price = 10; [instruction] | Construct a SQL statement updates the "products" table and sets the value of the "price" column to 10. [input] |
[output] | def longestPalindrome(st): palindromes = [] for i in range(len(st)): for j in range(i, len(st)): curr = st[i:j+1] rev = curr[::-1] if (curr == rev): palindromes.append(curr) res = max(palindromes, key = len) [instruction] | Answer what is the longest palindrome in a given string. [input] | "Run, spot, run. He ran up red hills"
[output] | def removeInts(arr): return [x for x in arr if type(x) is not int] print(removeInts(["Hello", 3, 5.4, "World", 6])) # output ['Hello', 5.4, 'World'] [instruction] | Create a filter to remove all integers from an array of mixed data types. [input] | ["Hello", 3, 5.4, "World", 6]
[output] | SELECT * FROM students WHERE GPA > 3.0; [instruction] | Create a SQL statement to select all rows of the "students" table with a GPA higher than 3.0. [input] |
[output] | def lastIndexOf(st, substr): if substr in st: start = -1 while True: pos = st.find(substr, start + 1) if pos == -1: break start = pos return start else: return -1 print(lastIndexO [instruction] | Construct a code to get the last index of a given substring in a string. [input] | "hi hi hello", "hi"
[output] | CREATE TABLE Airport ( aid INT, name VARCHAR(100), city VARCHAR(100), state VARCHAR(100), country VARCHAR(100), longitude DECIMAL(18,14), latitude DECIMAL(18,14), PRIMARY KEY(aid) ); [instruction] | Create a new table in an existing SQL database. [input] | The database called "airports" has the following table structure: Airport (aid, name, city, state, country, longitude, latitude)
[output] | A basic algorithm you can practice on FreeCodeCamp is Bubble Sort. Bubble Sort is an algorithm that sorts an array of elements by repeatedly swapping matched pairs of elements if they appear in the wrong order. It continues until no further swaps are needed, at which point the array is considered so [instruction] | FreeCodeCamp is a great platform for coding practice. Give an example of a basic algorithm you can practice on FreeCodeCamp. [input] |
[output] | 123.46875 in 8-bit binary is 1111011.01110000 [instruction] | Convert this floating-point number to an 8-bit binary number. [input] | 123.46875
[output] | The new array is [2, 3, 4, 5]. [instruction] | Create a new array using the given array and a given number. [input] | The given array is [2, 3, 4] and the given number is 5.
[output] | for x in range(1, 11): print(x) [instruction] | Create a loop in Python with the given requirements. [input] | Print out the numbers from 1 to 10, inclusive
[output] | Huffman encoding is an algorithm used for lossless data compression. It works by taking a string of data, analysing it and creating a shorter bit string that represents the same data. The data is compressed by assigning shorter codes to commonly occurring characters. This process reduces the amount [instruction] | Explain the use of the Huffman encoding algorithm. [input] |
[output] | function isSubsequence(str1, str2) { let i = 0; let j = 0; while (i < str1.length && j < str2.length) { if (str2[j] === str1[i]) { i++; } j++; } return i === str1.length; } [instruction] | Write a function in JavaScript that takes two strings as arguments and checks if the characters in the first string form a subsequence of the characters in the second string. [input] |
[output] | 0 [instruction] | For the given matrix, calculate the determinant. [input] | 1 2 3 4 5 6 7 8 9
[output] | #!/bin/bash # Restart network interfaces sudo ifconfig wlan0 down sudo ifconfig wlan0 up sudo ifconfig eth0 down sudo ifconfig eth0 up [instruction] | Create a linux shell script for restarting network interfaces. [input] |
[output] | Node* findMax(Node* root) { if (root == NULL) return root; Node* curr = root; while (curr->right != NULL) curr = curr->right; return curr; } [instruction] | Write a C++ program for finding the maximum value in a BST. [input] |
[output] | Machine learning is a field of Artificial Intelligence that focuses on developing algorithms for computers to learn from data and to make predictions about their environment. It can involve supervised and unsupervised learning techniques, such as classification and clustering, to analyze data and ma [instruction] | Describe the concept of machine learning in your own words. [input] |
[output] | def Fibonacci(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n): c = a + b a = b b = c return b for i in range(10): print(Fibonacci(i)) [instruction] | Generate multiple Fibonacci numbers in Python. [input] |
[output] | SELECT Name FROM Employees WHERE Salary > 50000; [instruction] | Create an SQL query to print the names of employees who are earning more than $50,000/year. [input] |