[output] | <a href="http://example.com" >Redirect Here</a> [instruction] | Modify the given HTML code so that it redirects to the page specified in the href attribute. [input] | <a>Redirect Here</a>
[output] | SELECT AVG(NumOrders) FROM (SELECT COUNT(OrderId) AS NumOrders FROM Orders WHERE State = 'CA' GROUP BY MONTH(OrderDate)) AS TotalOrders; [instruction] | Create a SQL query that returns the average number of orders per month for customers in California. [input] |
[output] | SELECT c.* FROM Customers c INNER JOIN (SELECT CustomerId, COUNT(OrderId) as NumOrders FROM Orders WHERE State = 'CA' GROUP BY CustomerId HAVING COUNT(OrderId) > 5) as Tot ON c.CustomerId = Tot.CustomerId; [instruction] | Create an SQL query to find all customers from California who made more than 5 orders. [input] |
[output] | The output of the query is 9.375. [instruction] | Calling a calculator API, what is the output of the query "3 * (9 + 5) / 8"? [input] |
[output] | SELECT SUM(OrderCost) FROM Orders o, Customers c WHERE o.CustomerId = c.CustomerId AND MONTH(c.DOB) = 5; [instruction] | Write an SQL query that returns the sum of all orders sent by customers who were born in the month of May. [input] |
[output] | The parity of the binary number 10101 is 1 (odd). [instruction] | Compute the parity of the following binary number. [input] | 10101
[output] | h1 { font-size: 16px; color: #00cc33; } [instruction] | Translate the following to CSS style. [input] | h1 {font-size: 16px; color: #00cc33;}
[output] | import numpy as np def average(arr): return np.average(arr) [instruction] | Use the numpy library to write a function that takes an array of integer values, and returns the average of all the values. [input] | arr = [1, 2, 3, 4, 5]
[output] | <script> window.onload = function(){ alert("Hello, World!"); } </script> [instruction] | Write a JavaScript code to pop up a window that says "Hello, World!" when you open up the webpage. [input] |
[output] | SELECT SUM(age) FROM students; [instruction] | Write a MySQL query to get the sum of all values for a certain field in a particular table. [input] | field_name = "age" table_name = "students"
[output] | public class Test { public static void main(String[] args) { System.out.println("My name is NAME"); } } [instruction] | Edit the Java code below to produce the output "My name is NAME". [input] | public class Test { public static void main(String[] args) { System.out.println("My name is"); } }
[output] | class BasketballPlayer: def __init__(self, name, age, height, weight): self.name = name self.age = age self.height = height self.weight = weight [instruction] | Create a Python class object to store data about a basketball player. [input] |
[output] | import requests response = requests.get(url) [instruction] | Use the requests library to write a Python program that sends an HTTP GET request. [input] | url = "http://example.com"
[output] | \b\w{4}\b [instruction] | Write a regex expression to find all the words in a given sentence that contain 4 characters. [input] | sentence = "This is a test sentence to find all 4 letter words"
[output] | SELECT * FROM table WHERE last_name LIKE 'C%'; [instruction] | Write a SQL query to display all rows with last_name starting with 'C'. [input] |
[output] | public class Book { // Properties private String title; private String author; private int yearPublished; // Constructors public Book (String t, String a, int y) { title = t; author = a; yearPublished = y; } // Accesso [instruction] | Create a class in Java that represent books in a library. [input] |
[output] | let data = [val1, val2, val3]; [instruction] | Write a piece of code to store 3 values in a single variable. [input] |
[output] | SELECT * FROM table WHERE col > 100; [instruction] | Write a SQL query to select all entries in a given table with a value larger than 100. [input] |
[output] | public boolean isValidDate(String date){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { format.parse(date); return true; } catch (ParseException e) { return false; } } [instruction] | Change the following piece of Java code to make sure that the parameter passed is a valid date. [input] | public boolean isValidDate(String date){ // return true if date is valid }
[output] | SELECT * FROM table WHERE col LIKE '%{value}%'; [instruction] | Write a SQL query to find all the entries in a given table that contain a specific“value” in the given column. [input] |
[output] | def number_divisible(x, y): for i in range(x): if i % y == 0 : print(i) [instruction] | Debug the following code and make sure the program runs as expected. [input] | def number_divisible(x, y): for i in range(x): if i % y = 0 : print(i)
[output] | <style> .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-gap: 10px; } </style> <div class="grid-container"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></ [instruction] | Write a HTML and CSS code that creates a 3x3 grid. [input] |
[output] | i = 1 while i <= 11: print(i) i = i + 1 [instruction] | Extend the given code to create a while loop that prints numbers from 1 to 11. [input] | i = 1 print(i)
[output] | class Person: def __init__(self,age=10): self.age = age [instruction] | Using the given class, write a constructor that creates an instance with age 10. [input] | class Person: def __init__(self,age): self.age = age
[output] | 5 [instruction] | Trace the program to find the output. [input] | def myfunc(x,y): if x == y: return x else: return "Not equal" a = myfunc(5,5) print(a)
[output] | String [instruction] | Classify the given data according to their type. [input] | hello
[output] | common_list = [] for num in list1: if num in list2: common_list.append(num) [instruction] | Compare two given lists to find the common elements and store the output in a new list. [input] | list1 = [1, 2, 3, 4, 5] list2 = [2, 4, 6, 8, 10]
[output] | import json data = { "name": "John", "age": 30, "status": "single" } data =json.loads(data) print(data['name']) [instruction] | Parse the JSON data stored in a variable 'data' and print out the value of the key 'name'. [input] | data = { "name": "John", "age": 30, "status": "single" }
[output] | # Delete 'customer' table from MySQL database import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", passwd="yourpassword", database="mydatabase" ) mycursor = mydb.cursor() sql = "DROP TABLE customer" mycursor.execute(sql) [instruction] | Write a code to delete a 'customer' table from a MySQL database. [input] |
[output] | def calc_perc(arr): count = 0 for num in arr: if num > 5: count +=1 return count/len(arr) *100 calc_perc([3, 4, 7, 8, 9, 11]) [instruction] | Calculate the percentage of numbers in an array that is greater than 5. [input] | [3, 4, 7, 8, 9, 11]