[output] | val wordCounts = df.flatMap(line => line.split(" ")) .map(word => (word, 1)) .reduceByKey(_ + _) .sort($"count".desc) [instruction] | Write an Apache Spark program to count the occurrence of each word in the given dataset. [input] |
[output] | SELECT * FROM products ORDER BY price DESC; [instruction] | Write an MySQL query to sort the records by the given field in descending order. [input] | field: "price"
[output] | SELECT first_name FROM Customer; [instruction] | Create a SQL query to retrieve the first name of each customer. [input] | Table name = Customer
[output] | SELECT MONTHNAME(date), SUM(amount) AS total_sales FROM Sales GROUP BY MONTH(date); [instruction] | Create a MySQL query to summarize total sales for each month. [input] | Table name = Sales
[output] | for i in range(20): print("Hello World") [instruction] | Write a script to display "Hello World" in the console twenty times [input] |
[output] | <div style="width: 200px; padding: 5px 10px; border-radius: 5px; background-color: #f5f5f5;"> <div style="border: 1px solid #dedede; padding: 10px; background-color: #fff;"> <p>Hello World!</p> </div> </div> [instruction] | Generate an HTML code to display the following speech bubble [input] |
[output] | #include <stdio.h> #include <string.h> int main() { /* Input String */ char str[] = "Hello World!"; int index; /* Specified Character */ char ch = 'o'; index = 0; /* Remove the character from the string */ while (str[index] != '\0') { /* If the ch [instruction] | Create a C program to remove a specified character from a given string. [input] | String = "Hello World!", Character = 'o'
[output] | SELECT * FROM Item WHERE price > 10; [instruction] | Write an SQL script to list all items with a price greater than 10$. [input] | Table Name = Item
[output] | public static void bubbleSort(int[] arr) { int n = arr.length; int temp = 0; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(arr[j-1] > arr[j]){ temp = arr[j-1]; arr[j-1] = arr[j]; arr[j] = temp; } } [instruction] | Create a program in Java that sort a given array using bubble sort algorithm. [input] | Array: [4, 3, 5, 2, 1]
[output] | 8 / (2 * (2 + 2)) // parentheses moved to form the correct expression which yields the correct answer (16). [instruction] | Move the parentheses to make the expression give the correct answer. [input] | Expression: 8 / 2 * (2 + 2) Answer: 16
[output] | No syntax errors were detected in the given statement. [instruction] | Analyze the given statement for any syntax errors. [input] | Statement: The user entered his name James and password1234
[output] | def fibonacci(num): fib_list = [0, 1] if num == 0: return [] elif num == 1: return [0] else: for _ in range(2, num): nxt_num = fib_list[-1] + fib_list[-2] fib_list.append(nxt_num) return fib_list [instruction] | Write a function to generate Fibonacci numbers in Python. [input] |
[output] | Advantages of FOR loop: - It provides a simple, efficient way to write the loop and is easy to read. - It is useful in certain scenarios where you need to control the number of iterations. Disadvantages of FOR loop: - It requires you to specify the number of iterations at the start of the loop. [instruction] | List the advantages and disadvantages of using a FOR loop. [input] |
[output] | Regex: ^\d{10}$ [instruction] | Construct a regex to check if a provided string is phone number or not [input] |
[output] | def reverse_list(l): return l[::-1] [instruction] | Write code for reversing a list in Python [input] | [1,2,3,4]
[output] | { "firstName": "John", "lastName": "Doe", "age": 23 } [instruction] | Convert the Python Dictionary given below into a valid JSON [input] | { "firstName": "John", "lastName": "Doe", "age": 23 }
[output] | SELECT name FROM employees WHERE YEAR(join_date) = 2018 [instruction] | Write SQL query to retrieve the names of employees who joined in the year 2018 [input] |
[output] | Student Name | Math | English | Physics | Chemistry -------------|------|---------|---------|----------- John | 70 | 80 | 87 | 85 Mary | 90 | 65 | 70 | 79 [instruction] | Create a spreadsheet and enter the following data [input] | Student Name Math English Physics Chemistry John 70 80 87 85 Mary 90 65 70 79
[output] | def count_ways(n): if n==1 or n==0: return 1 elif n==2: return 2 else: return count_ways(n-1) + count_ways(n-2) + count_ways(n-3) [instruction] | Create a function to calculate the number of different ways to climb n stairs [input] |
[output] | <table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>Item 1</td> <td>Value 1</td> </tr> <tr> <td>Item 2</td> <td>Value 2</td> </tr> </table> [instruction] | Compose the html for the following table [input] | Column 1 | Column 2 ------------------- Item 1 | Value 1 Item 2 | Value 2
[output] | HELLO WORLD [instruction] | Convert the following string from lower case to upper case [input] | hello world
[output] | def most_common(arr): counts = {} for i in arr: if i in counts: counts[i] += 1 else: counts[i] = 1 max_count = 0 max_item = None for item, count in counts.items(): if count > max_count: max_count = count [instruction] | Create an algorithm to determine the most common element in an array [input] | [2, 3, 5, 3, 7, 2, 8, 1, 3]
[output] | .table-left { float: left; } [instruction] | Design a CSS class to align a table to the left of the page? [input] |
[output] | console.log("Process started"); alert("Process Completed Successfully"); [instruction] | Edit the given JavaScript code to alert a success message? [input] | console.log("Process started");
[output] | Mercurial and Git are both distributed version control systems, meaning that all users have a complete copy of the repository. Both are extremely fast, with Git being slightly faster than Mercurial. Mercurial has a few advantages over Git, such as better merging capabilities, sophisticated branch ma [instruction] | Compare the features of Mercurial and Git. [input] |
[output] | An XML document has a basic structure of a root element, which may contain other elements. Elements in an XML document are defined by start tags and end tags and can have attributes, text and other kinds of content. In addition, there are rules regarding the order of nested elements, the type of ele [instruction] | Describe the basic structure of an XML document [input] |
[output] | p { font-weight: bold; } [instruction] | Create a CSS rule to apply bold font style to all <p> tags. [input] |
[output] | There is no limit to the number of arguments that can be passed to a JavaScript function. However, this limit depends on the browser and its implementation. In Chrome and Firefox, the maximum number of arguments that can be passed to a function is limited only by the available memory. [instruction] | How many arguments can be passed to a JavaScript function [input] |
[output] | class Circle { constructor(radius) { this.radius = radius; } get area() { return Math.PI * this.radius * this.radius; } } [instruction] | Create a JavaScript class for a circle that calculates its area and returns the result. [input] |
[output] | <html> <head> <title>HTML Div Test</title> </head> <body> <div style="width:50px; height:100px;">Div 1</div> <div style="width:50px; height:100px;">Div 2</div> <div style="width:50px; height:100px;">Div 3</div> </body> </html> [instruction] | Generate a HTML document with 3 divs, each div being 50px wide and 100px tall [input] |