[output] | SELECT * FROM products WHERE price > 10; [instruction] | Develop a query in SQL to display all columns from a table named 'products' with a product price greater than 10. [input] |
[output] | // Operator Overloading in C++ class MyClass { public: int x; // Overload + operator to add two objects. MyClass operator +(const MyClass &obj) { MyClass res; res.x = x + obj.x; return res; } }; [instruction] | Write an expression using operator overloading in C++ to simulate addition of two objects. [input] |
[output] | for (int i = 4; i > 0; i--) { System.out.print(i + " "); } [instruction] | Compose a for loop in Java to print the numbers from 4 to 1 one line. [input] |
[output] | words = sentence.split(" ") [instruction] | Write code in Python to extract all the words from a sentence and store them in an array. [input] | "Hello World!"
[output] | # A function to do preorder tree traversal def preOrder(root): # Base Case if root is None: return # First print the data of node print(root.data), # Then recur on left child preOrder(root.left) # Finally recur on right child preOrder(root.right) [instruction] | Create an algorithm to traverse a binary tree in pre-order in Python. [input] |
[output] | #!/bin/bash # Navigates to the given directory cd $1 # Print all contents of the directory ls [instruction] | Create a script in Bash to navigate to a given directory and list all its contents. [input] |
[output] | let maxNum = [1, 2, 3, 4, 5].reduce(function(a, b){ return Math.max(a, b) }); [instruction] | Use the reduce method in JavaScript to find the maximum value in a given array. [input] | [1, 2, 3, 4, 5]
[output] | <html> <head> <title>Input Form</title> </head> <body> <form> Name:<br> <input type="text" name="name"><br> Age:<br> <input type="number" name="age"><br> Gender:<br> <input type="radio" name="gender" [instruction] | Create a web page that contains three input boxes for a user to input name, age, and gender. [input] |
[output] | SELECT COUNT(*) FROM table_name; [instruction] | Generate a valid SQL query that finds out the number of rows stored in a table [input] |
[output] | <html> <head> <title>Basic Webpage</title> </head> <body> </body> </html> [instruction] | Create a basic HTML skeleton for a web page. [input] |
[output] | for (let i = 0; i < 10; i++) { console.log(`Iteration number ${i}`); } [instruction] | Write a for loop in JavaScript that iterates 10 times and prints a message each time. [input] |
[output] | <html> <head> <title>User Information Form</title> </head> <body> <form> First Name:<br> <input type="text" name="firstname"><br> Surname:<br> <input type="text" name="surname"><br><br> <input type="submit"> </form> </body> </html> [instruction] | Create a basic form in HTML containing two input boxes for first name and surname. [input] |
[output] | import java.util.HashMap; public class Anagram { // Utility method to check whether two strings are anagram or not static boolean areAnagram(String A, String B) { // If length of both strings is not same, then they can't be anagram if (A.length() != B.length()) [instruction] | Write a Java program that prompts the user to enter two strings and outputs whether the two strings are anagrams. [input] |
[output] | def sort_str(str1, str2): # extract the words from the strings str1_list = list (map (str, str1)) str2_list = list (map (str, str2)) # sort the strings str1_list.sort() str2_list.sort() # join the chars of the strings sorted_str1 = ''.join(str1_list) [instruction] | Given two strings, sort them in alphabetically ascending order. [input] | "javascript" "python"
[output] | import re def isValidIP(ip): # check if the string is a valid IP address regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)'' [instruction] | Write a Python program to determine if an input string is a valid IP address. [input] |
[output] | SELECT AVG(age) FROM students WHERE class = 'XYZ'; [instruction] | Write an SQL query that returns the average age for students in a specific class. [input] |
[output] | def spiralPrint(m, n, a) : k = 0; l = 0 ''' k - starting row index m - ending row index l - starting column index n - ending column index i - iterator ''' while (k < m and l < n) : # Print the first row from the remaining [instruction] | Write a function to print the spiral ordering of an input matrix. [input] | [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[output] | SELECT * FROM table ORDER BY Score; [instruction] | Create a SQL query to sort a table by its numerical contents. [input] | Table: +-----------+-----------+ | Name | Score | +-----------+-----------+ | John | 90 | | Mary | 80 | | Miguel | 75 | | Fanny | 99 | +-----------+-----------+
[output] | /hello\s+people/ [instruction] | Write a regular expression to match the phrase "hello people" [input] |
[output] | .left-align { text-align: left; } [instruction] | Create a CSS class that aligns its content left. [input] |
[output] | <input type="text" required> [instruction] | Construct an HTML form element to define a required input field. [input] |
[output] | for (let i = 0; i < 5; i++) { ... } [instruction] | Create a JavaScript loop with the condition i < 5. [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 fibonacci(n) [instruction] | Write a function in Python to return the first n digits of the Fibonacci sequence. [input] | n = 5
[output] | int numbers[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; [instruction] | Create an array in C++ of 10 integers and assign them all to 0. [input] |
[output] | SELECT Item, Category FROM table GROUP BY Category; [instruction] | Construct a query in SQL to group records by some value. [input] | Table: +-----------+-----------+ | Item | Category | +-----------+-----------+ | Pencil | Office | | Phone | Electronics| | Pen | Office | | Monitor | Electronics| +-----------+-----------+
[output] | public class Example{ public int num; public Example(int num){ this.num = num; } } [instruction] | Create a C# class that contains a constructor. [input] |
[output] | for i in range(10): ... [instruction] | Create a Python loop that iterates for 10 times. [input] |
[output] | Regex: https?://[\w\d./]+ [instruction] | Create a regex to extract links from a block of text [input] | Text: The website www.example.com has great resources
[output] | @function text-color($text-color, $background-color) { // Calculate how much Black and White needs to be in the text to be readable $res: 0; $black: 0; $white: 0; @if (lightness($background-color) > 50) { // Use black on light backgrounds $black: 100%; $white: (1 - ( (255 - ( [instruction] | Create a sass function to change the text color of a web page [input] |
[output] | //*[@id="myElement"] [instruction] | Write an XPATH expression to select an element with a specific id [input] |