[output] | pattern = r'\b[0-9]\w+' [instruction] | Write a regular expression pattern to find all the words which begin with a digit. [input] |
[output] | import json json_data = '{"name":"John", "age":30}' data = json.loads(json_data) name = data["name"] age = data["age"] print(f"Name: {name}, Age: {age}") [instruction] | Parse a JSON string. [input] | {"name":"John", "age":30}
[output] | class Queue: def __init__(self): self.data = [] def is_empty(self): return not self.data def enqueue(self, element): self.data.append(element) def dequeue(self): return self.data.pop(0) def peek(self): if not self.is_empty(): [instruction] | Implement a queue data structure. [input] |
[output] | """ Run a sentiment analysis of the sentence using Python """ import nltk from textblob import TextBlob text = 'The food was really good but the service was terrible.' blob = TextBlob(text) for sentence in blob.sentences: print(sentence.sentiment) # Output Sentiment(polarity=0.05, subjectiv [instruction] | Run a sentiment analysis of the following sentence using Python. [input] | The food was really good but the service was terrible.
[output] | SELECT * FROM orders ORDER BY created_at ASC LIMIT 1; [instruction] | Create a MySQL query to retrieve the oldest record in a table called orders. [input] |
[output] | """ Write a code to convert any string to camel case format in Java """ public class CamelCaseFormat { public static String toCamelCase(String s){ String[] parts = s.split("_"); String camelCaseString = ""; for (String part : parts){ camelCaseString = camelCas [instruction] | Write a code in Java to convert any string to camel case format. [input] | String = "this_is_a_string"
[output] | Heap or binary tree. A heap or binary tree data structure are most suitable for storing a large list of numbers as it provides O(log n) time complexity for insertion, search and deletion. [instruction] | Which data structure is most suitable for storing a large list of numbers? [input] |
[output] | Depth-first search (DFS) is an algorithm used to traverse a tree or graph data structure. It starts at the root of the tree, explores as far as possible down a given branch and then backtracks along the same path before exploring a new branch. For example, consider a BST (Binary Search Tree) where w [instruction] | Explain the concept of the depth-first search algorithm and provide an example. [input] |
[output] | SELECT name, address, contact_number FROM customers ORDER BY spending DESC LIMIT 1; [instruction] | Create a SQL query to retrieve the name, address and contact number of the customers with the highest spending record. [input] |
[output] | Fuzzy logic is a form of artificial intelligence that deals with reasoning that is approximate rather than exact. It is based on the concept of fuzzy sets, which allow for degrees of truth instead of just true and false. For example, "It's hot" is a fuzzy statement because there is no definite tempe [instruction] | Explain the concept of fuzzy logic and provide an example. [input] |
[output] | nums = [1,2,3,4,5] sum = 0 for num in nums: sum +=num average =sum / len(nums) print(average) // output is 3.0 [instruction] | Given a data set, calculate the average using Python. [input] | [1, 2, 3, 4, 5]
[output] | SELECT * FROM employee WHERE name = 'John' [instruction] | Format the following SQL query using indentation. [input] | SELECT * FROM employee WHERE name = 'John'
[output] | for i in range(101): print(i) [instruction] | Using Python, create a program that prints out the numbers 0 to 100. [input] |
[output] | SELECT * FROM employee [instruction] | Create a query in PostgreSQL to display all the records in a given table. [input] | Table name: 'employee'
[output] | div { background-color: red; } [instruction] | Write a basic CSS structure to style a div element with the background colour of 'red'. [input] |
[output] | SELECT name FROM people WHERE year_of_birth <1990; [instruction] | Write a SQL query to find all the names of people born before 1990. [input] |
[output] | <html> <head> <title>My Website</title> </head> <body> <header> <div class = "logo"> <img src = "logo.png" alt = "Website Logo" /> </div> </header> <!-- other code--> </body> </html> /* CSS Code */ header { background-color: #ccc; padding: 30px 0; } .logo { text-align: center; [instruction] | Create a HTML & CSS website template featuring a header with a website logo. [input] |
[output] | There are over 700 islands in Scotland, with approximately 150 of them being inhabited. [instruction] | How many islands of Scotland are there? [input] |
[output] | import flask app = flask.Flask(__name__) students = { 'John': 20, 'Jane': 19, 'Bob': 22 } @app.route("/get_student_ages", methods = ["GET"]) def get_student_ages(): return flask.jsonify(students) if __name__ == "__main__": app.run() [instruction] | Develop an API that returns a list of students and their ages. [input] |
[output] | class Employee: def __init__(self, name, age, salary): self.name = name self.age = age self.salary = salary employee_list = [] [instruction] | Create a data structure to store employee information. [input] |
[output] | SELECT * FROM customers WHERE EXISTS (SELECT * FROM orders WHERE customers.CustomerID = orders.CustomerID AND orders.OrderDate > NOW() - INTERVAL 30 DAY) [instruction] | Write a MySQL query to find all the customers who have placed an order in the last 30 days. [input] |
[output] | name@example.com is a valid email address. [instruction] | Identify which of these strings is a valid email address? [input] | name@example.com,lily.flower@example.net,www@example.org
[output] | 12 [instruction] | Choose the correct output of the following program. [input] | x = 3 y = 4 z = 5 if x < y and y < z: print(x + y + z)
[output] | def detect_negative_number(numbers): flag = False for num in numbers: if num < 0: flag = True break return flag [instruction] | Create a program to detect a negative number in an array of numbers. [input] | numbers = [10, -5, 4, 20]
[output] | func capitalizeFirstLetter(sentence: String) ->String { return sentence.prefix(1).uppercased() + sentence.dropFirst() } [instruction] | Write a method in Swift to capitalize the first letter of a given sentence. [input] | sentence = "hello world"
[output] | SELECT * FROM users WHERE username LIKE 'John%'; [instruction] | Search for Usernames starting with “John” in the database. [input] |
[output] | def permutations(arr): # base case: if len(arr) == 0: return [] # base case: if len(arr) == 1: return [arr] # find all permutations for arr of size n-1 smaller_permutations = permutations(arr[1:]) # find permutations for element at the index 0 c [instruction] | Generate permutations of the given array of numbers. [input] | numbers = [1, 2, 3]
[output] | def getTriangularNumber(n): return int(n * (n + 1) / 2) [instruction] | Write a function to calculate the triangular number of a given number n. [input] |
[output] | def check_if_pair_exists(arr_a, arr_b): for i in range(len(arr_a)): for j in range(len(arr_b)): if arr_a[i] == arr_b[j]: return True return False [instruction] | Design algorithm for the below use case [input] | Given two arrays A and B of the same length, determine whether there is a pair of indices (i, j) such that A[i] == B[j].
[output] | def polynomial_eqn(x): y = 3 * x**3 + 4 * x - 2 return y [instruction] | Write the pseudo-code algorithm that implements the following polynomial equation [input] | 3x^3 + 4x - 2