[output] | def detect_char_type(ch): char_type = "" if ch.isalpha(): char_type = "Letter" elif ch.isdigit(): char_type = "Digit" elif ch.isspace(): char_type = "Space" elif ch in string.punctuation: char_type = "Punctuation" else: char_type = "Special Character" return cha [instruction] | Create a program to detect the type of a given character. [input] |
[output] | <html> <head> <title>Hello, World!</title> </head> <body> <h1>Hello, World!</h1> </body> </html> [instruction] | Create a HTML page which displays "Hello, World!" on the screen. [input] |
[output] | def multiply(A, B): # initialize result matrix rows_A = len(A) cols_A = len(A[0]) rows_B = len(B) cols_B = len(B[0]) if cols_A != rows_B: print("Cannot multiply the two matrices. Incorrect dimensions.") return # construct result matrix C [instruction] | Design an algorithm for multiplying two matrices. [input] | A = [[1, 2,], [3, 4]] B = [[5, 6], [7, 8]]
[output] | def multiple_table(): for i in range(1, 13): for j in range(1, 13): print("%2d x %2d = %3d" %(i, j, i*j)) print("\n") multiple_table() [instruction] | Can you print out a multiplication table of size 12 by 12? [input] |
[output] | def Fibonacci(num): a = 0 b = 1 if num < 0: print("Incorrect input") elif num == 0: return a elif num == 1: return b else: for i in range(2,num): c = a + b a = b b = c return b [instruction] | Design a code to generate Fibonacci numbers. [input] |
[output] | def get_domain(url): parsed_url = urllib.parse.urlparse(url) return parsed_url.netloc [instruction] | Can you parse a given URL and extract the domain name? [input] |
[output] | public class BinarySearch { public static double search(int[] arr, int target) { int low = 0; int high = arr.length - 1; while (low <= high) { int mid = (low + high) / 2; if (target == arr[mid]) { return mid; } [instruction] | Create an algorithm in Java to search for a given value in a sorted array of integers. [input] |
[output] | function areSameWord(str1, str2) { str1 = str1.toLowerCase(); str2 = str2.toLowerCase(); if (str1 === str2) { return true; } else { return false; } } [instruction] | Compose a JavaScript function to detect whether two strings are punctuated versions of the same word. [input] | String1: 'apple' String2: 'Apple'
[output] | class Sum { public static void main(String[] args) { int[] arr = {1,2,3,4,5}; int max = arr[0]; int min = arr[0]; int sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; if (arr[i] > max) { max = [instruction] | Write a Java program to sum the elements of an array except for the maximum and minimum. [input] | Array: [1, 2, 3, 4, 5]
[output] | # converting the string to upper-case string = "Experiment" print("Old String:", string) string = string.upper() print("New String:", string) [instruction] | Compose a Python script to convert a string to an all-uppercase string. [input] | String: 'Experiment'
[output] | <table> <tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> </tr> </table> [instruction] | Generate some HTML code to create a table with 3 columns. [input] |
[output] | class CompoundInterest { static double compoundInterest(double principal, double time, double rate, double n) { return principal * (Math.pow((1 + rate / n), n * time)); } public static void main(String[] args) { double principal = 1000; double tim [instruction] | Write a Java program to calculate the compound interest. [input] | Principal (P): 1000 Time (T): 2 Rate of Interest (R): 10 Number of Compounds (N): 4
[output] | using System; namespace SortString { class Program { static void Main(string[] args) { string[] fruits = { "banana", "apple", "orange" }; Array.Sort(fruits); Console.WriteLine("Sorted Array of strings:"); foreach (string frui [instruction] | Implement a C# program that reads an array of strings and sorts them in alphabetical order. [input] | Array of Strings: ["banana", "apple", "orange"]
[output] | function convertISODate(ISOdateString) { const date = new Date(ISOdateString); const dateString = date.toLocaleString('default', {day: 'numeric', month: 'long', year:'numeric'}); return dateString; } console.log(convertISODate('2020-06-15')); // Output: June 15, 2020 [instruction] | Develop a JavaScript function to convert a date string from the ISO-8601 format to a human-readable format. [input] | Date String: '2020-06-15'
[output] | import os import smtplib from email.message import EmailMessage def sendEmail(request): request_json = request.get_json() name = request_json.get('name') message = request_json.get('message') SENDER = os.environ.get('SENDER') RECEIVER = os.environ.get('RECEIVER') PASSWORD [instruction] | Create a GCP Cloud Function that sends an email with input "name" and "message". [input] |
[output] | { "name": "John Doe", "age": 30 } [instruction] | Create a JSON object that contains "name" and "age" fields. [input] |
[output] | The derivative of f(x) is f'(x) = 2x + 5 [instruction] | Find the derivate of this equation: f(x) = x^2 + 5x + 3 [input] |
[output] | for(int i=0; i<array.length; i++) { System.out.println(array[i]); } [instruction] | List the elements of this array in console. [input] | array = [22, 74, 12, 1]
[output] | import numpy as np from sklearn.cluster import KMeans # Create dataset dataset = np.array([[5,7], [1,2], [7,9], [10,2], [2,5]]) # Create KMeans object kmeans = KMeans(n_clusters=2) # Fit the model kmeans.fit(dataset) # Get labels labels = kmeans.labels_ # Calculate cluster centers using the ave [instruction] | Perform K-Means Clustering on this dataset. [input] | dataset = [[5,7], [1,2], [7,9], [10,2], [2,5]]
[output] | .rounded-corners { border-radius: 15px; } [instruction] | Write a CSS class for setting rounded corners. [input] |
[output] | string = "1.25" float_value = float(string) [instruction] | Convert this string to a float in Python. [input] | string = "1.25"
[output] | mutation addUser { addUser(name: "User1", email: "user1@test.com") { name email } } [instruction] | Create a graphql mutation that adds a new user to the system. [input] | name: "User1", email: "user1@test.com"
[output] | <?php $joined = implode(array('a', 'b', 'c')); echo $joined; [instruction] | Change the following PHP code to use the new syntax from PHP 7 [input] | <?php $joined=join(array(‘a’,’b’,’c’)); echo $joined;
[output] | \<div\>(.*?)\</div\> [instruction] | Write a RegEx to extract text inside tags [input] | <div>This is a test</div>
[output] | def permutation(str): if len(str) == 0: return [''] prev_list = permutation(str[1:len(str)]) next_list = [] for i in range(0,len(prev_list)): for j in range(0,len(str)): new_str = prev_list[i][0: j]+str[0]+prev_list[i][j: len(str)-1] if [instruction] | Create a permutation of characters in a string. [input] | str = "CAT"
[output] | The first line of code is used to replace all occurrences of "old" with "new" in string. The second line of code is used to strip all trailing whitespace from the string. [instruction] | What do the following two lines of code do? [input] | string.replace('old', 'new') string.rstrip()
[output] | <!DOCTYPE html> <html> <head> <title>AJAX Example</title> <script> function loadData(){ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("data").innerHTML = this.responseText; [instruction] | Add AJAX functionalities to the following HTML document. [input] | <!DOCTYPE html> <html> <head> <title>AJAX Example</title> </head> <body> </body> </html>
[output] | Webhooks are useful for server-side applications as they allow programs to receive real-time updates from external services. Instead of the application periodically polling for changes, webhooks allow for the external service to make an HTTP POST request to the application each time an event occurs. [instruction] | Explain the use of webhooks in server-side applications [input] |
[output] | """ Implementing the Levenshtein distance algorithm in Python """ def levenshtein(word1, word2): """Calculate the Levenshtein distance between two words""" size_x = len(word1) + 1 size_y = len(word2) + 1 matrix = [[0 for i in range(size_x)] for j in range(size_y)] for x in rang [instruction] | Implement the Levenshtein distance algorithm in Python. [input] |
[output] | positive [instruction] | given a sentence, classify it into positive or negative sentiment. [input] | I can't wait to get home and relax.