[output] | SELECT letter, COUNT(*) as Frequency FROM letters GROUP BY letter ORDER BY Frequency DESC LIMIT 3; [instruction] | Write a MySQL query to get the top 3 most frequent letters [input] | Table ‘letters’ containing letters
[output] | temp = nums[len(nums) - 1] for i in range(len(nums) - 1, 0, -1): nums[i] = nums[i - 1] nums[0] = temp [instruction] | Change the code to have an array shift right by one without using built-in functions [input] | nums = [1, 2, 3, 4, 5]
[output] | def num_common_chars(str1, str2): count = 0 for x in str1: if x in str2: count += 1 return count [instruction] | Come up with a program that takes in two strings and returns the number of characters that are shared between them [input] | str1 = "Greatest" str2 = "Gifted"
[output] | def is_sorted(arr): n = len(arr) for i in range (0, n-1): if (arr[i] > arr[i+1] ): return False return True [instruction] | Edit the code so it can detect if an array is already sorted [input] | arr = [1, 2, 4, 5, 6, 7]
[output] | SELECT COUNT(DISTINCT salary) FROM employee_salary; [instruction] | Come up with a query to count the number of distinct elements in a table [input] | Table "employee_salary"
[output] | ^\d{5}(-\d{4})?$ [instruction] | Create a regex pattern to match a valid US zipcode [input] |
[output] | def Contains(nums, target): for i in range(len(nums)): if nums[i] == target: return True print("Index not found") return False [instruction] | Edit the code to print out that "Index not found". [input] | nums = [1, 2, 3, 4, 5] target = 6
[output] | if num < 0: print("Error: Please enter a positive number!") else: print("Great, the number is positive.") [instruction] | Edit the code to print out an error message if a negative number is entered as input [input] | num = -5
[output] | def common_words(str1, str2): l1 = str1.split() l2 = str2.split() result = list(set(l1) & set(l2)) return result [instruction] | Create a program that takes in two strings and prints out common words [input] | str1 = "The quick brown fox" str2 = "The brown rabbit"
[output] | ALTER TABLE Employee ADD new_column INT [instruction] | Come up with a query to add a new column to a table [input] | Table ‘employee’
[output] | <html> <head> <title>Data Table</title> </head> <body> <h1>Data Table</h1> <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Harry</td> <td>18</td> [instruction] | Generate a HTML table to display the following data. [input] | Row1: Name: Harry Age: 18 Row2: Name: Jane Age: 20
[output] | SELECT FirstName, LastName FROM Employees WHERE Department = 'IT'; [instruction] | Write a SQL query to display the names of all employees who belong to department 'IT'. [input] |
[output] | The sum of the given array of numbers is calculated using the addition operation. [instruction] | Identify the operations used to calculate the sum of the given array of numbers. [input] | Array: [2, 3, 8, 9]
[output] | [2, 5, 28, 7, 37] [instruction] | Update the given list of numbers such that the first number is subtracted from the second one, the third is multiplied by the fourth, and the result is added to the fifth. [input] | [2, 5, 4, 7, 9]
[output] | 12 [instruction] | Output the remaining result after subtracting 5 from a given number. [input] | Number: 17
[output] | Print("Welcome! You are {age} years old") [instruction] | Print a message based on the given age. [input] | Age: 32
[output] | def isArmstrong(num): # obtain number of digits digits = len(str(num)) # initialize sum Sum = 0 # find sum of nth power of digits temp = num while temp > 0: digit = temp % 10 Sum = Sum + digit ** digits temp //= 10 # return true or false return Sum = [instruction] | Write a function to check if a given number is an Armstrong number or not. An Armstrong number is a-number when the sum of the cubes of its own digits is equal to the number itself. [input] |
[output] | 7.5 [instruction] | Output the median of the given list of numbers. [input] | [1, 4, 7, 9, 12]
[output] | H#ll# W#rld [instruction] | Replace all vowels (except y) in the given text with a given character. [input] | Text: Hello World Character: #
[output] | pragma solidity ^0.6.0; contract Will { address owner; constructor () public { owner = msg.sender; } function executeWill () public { // execute will here // code to check if testator is alive } } [instruction] | Create a smart contract in solidity for executing a will. [input] | The will is to be activated when the testator is no longer alive.
[output] | JOIN is a SQL command used to retrieve data from two or more related tables. It is used to combine data from multiple tables in a single query, by matching values from each of the tables to create a result set. JOIN can be used to combine rows from different tables based on a common value which is s [instruction] | In SQL, what is JOIN used for? [input] |
[output] | from django.contrib.auth.models import User from django.http import HttpResponse from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt from .models import Search @csrf_exempt def search_text(request): if request.method == 'PUT': data = request.PUT [instruction] | Create an api with Django that is able to search through an inputed text. [input] |
[output] | In React, state is an object that stores data which can be accessed and modified by components. State is used to keep track of dynamic data in a component and can be initialized during the component's constructor or lifecycle methods. Components can modify a component's state using the setState() me [instruction] | In a React web application, how do you define state? [input] |
[output] | list = [1, "hello", {'name': 'John'}] [instruction] | Create a list of 3 objects in Python. [input] |
[output] | The HTML element can be moved to the bottom of a page by using the 'position: absolute' and 'bottom: 0px' CSS properties. [instruction] | How can be an HTML element moved to the bottom of a page? [input] |
[output] | #include <stdio.h> int main() { int a, b, sum; /* Input two numbers from user */ printf("Enter two numbers: "); scanf("%d%d", &a, &b); sum = a + b; printf("Sum = %d", sum); return 0; } [instruction] | Generate a program in C that computes the sum of two numbers. [input] |
[output] | Algorithm: // Step 1: Set two pointers, start and end initially pointing to 0 and the last element respectively. start = 0; end = arr.length - 1; // Step 2: Swap the elements at pointer start and end. swap(arr[start], arr[end]); // Step 3: Increment start pointer and decrement end pointer. start+ [instruction] | Produce an algorithm to reverse the elements of an array. [input] | Array: [1, 2, 3, 4, 5]
[output] | SELECT customer_name, contact_number, purchase_amount FROM Customer WHERE purchase_amount > 500; [instruction] | Write a SQL query to display the customer name, contact number and purchase amount for customers who made a purchase above $500. [input] | Table name: Customer
[output] | class Dog: def __init__(self,name, age, breed): self.name = name self.age = age self.breed = breed [instruction] | Create a class named Dog with parameters name, age and breed. [input] |
[output] | function circleArea(radius) { return Math.PI * radius * radius; } [instruction] | Create a JavaScript function to calculate the circle area given the radius. [input] |