[output] | def polar_rep(point): x, y = point r = math.sqrt(x**2 + y**2) theta = math.atan2(y, x) return (r, theta) [instruction] | Convert a given 2D point to the polar representation. [input] | Point: (1,1)
[output] | [24, 18, 13, 37, 11, 87, 71, 6, 45, 97] [instruction] | Create an array with 10 random elements. [input] |
[output] | SELECT MIN(Price) FROM Products; [instruction] | Create a SQL query to find the least expensive product. [input] |
[output] | def foo(a, b, c): return a + b + c [instruction] | Modify the following code to display alter the existing function to accept an additional parameter. [input] | def foo(a, b): return a + b
[output] | import re list = re.findall(r'\d+', s) [instruction] | Parse a list of numbers from a string in Python. [input] | s = "1, 2, 3, 4, 5, 6"
[output] | string.trim(); [instruction] | You need to trim a string by removing leading and trailing whitespace characters. [input] | string = " hello "
[output] | import java.util.Scanner; public class Test { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.print("Enter in a name: "); String name = scanner.nextLine(); System.out.println("Hello, " + name + "!"); } } [instruction] | Modify the given program to print "Hello, foo" where "foo" is user input. [input] | System.out.println("Hello, World!");
[output] | def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) [instruction] | Create a Python program to define a factorial of a given number. [input] |
[output] | def print_elements(my_list): if not my_list: return print(my_list[0]) print_elements(my_list[1:]) [instruction] | Define a function to print out the elements in a list without using a loop. [input] |
[output] | print("Welcome to coding!") [instruction] | Edit the code to display the output “Welcome to coding!” [input] | print("Welcome to code")
[output] | camel Case String [instruction] | Convert the following text from a camel case string to a space-separated one. [input] | camelCaseString
[output] | def rotate_90_degrees(matrix): n = len(matrix[0]) result = [[0 for x in range(n)] for y in range(n)] for i in range(n): for j in range(n): result[j][n-i-1] = matrix[i][j] return result [instruction] | Make an algorithm to rotate a matrix by 90 degrees. [input] | [[1,2,3], [4,5,6], [7,8,9]]
[output] | def Fibonacci(n): if n<0: print("Incorrect input") # First Fibonacci number is 0 elif n==0: return 0 # Second Fibonacci number is 1 elif n==1: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) [instruction] | Design a recursive algorithm to generate the Fibonacci sequence. [input] |
[output] | //Reusable "push" and "pop" functions void push(Stack *st, int val) { st->arr[st->top] = val; st->top++; } int pop(Stack *st) { return st->arr[--(st->top)]; } //Functions for performing operations int add(Stack *st) { int x = pop(st); int y = pop(st); return x + y; } int [instruction] | Write a stack-based language for a simple calculator that can perform the following tasks: Add, subtract, multiply, and divide integers. [input] |
[output] | CREATE TABLE Students ( student_id INT NOT NULL AUTO_INCREMENT, student_name VARCHAR(50) NOT NULL, student_age INT NOT NULL, PRIMARY KEY (student_id) ); CREATE TABLE Courses ( course_id INT NOT NULL AUTO_INCREMENT, course_name VARCHAR(50) NOT NUL, course_duration INT NOT [instruction] | Create a SQL database with two separate tables named "Students" and "Courses" to store relevant information about student records. [input] |
[output] | //HTML code <h1>Current Time By Country</h1> <ul> <li>New York: <span id="new-york-time"></span></li> <li>Tokyo: <span id="tokyo-time"></span></li> <li>London: <span id="london-time"></span></li> </ul> //JavaScript code function getTimeByCountry() { // Set current time for New Yor [instruction] | Build a web application to display the current time in different countries. [input] |
[output] | public class PrintPosition { public static void printPosition(String str) { for (int i = 0; i < str.length(); i++) { System.out.println("Character '" + str.charAt(i) + "' is at position " + i); } } } [instruction] | Create a class in Java that performs the following task: print out all characters of a given string along with their position in the string. [input] |
[output] | import React from "react"; //React component const ZipCodeInformation = (props) => { const zipCode = props.zipCode; return ( <div> <h2>Zip Code Information</h2> <ul> <li>Zip Code: {zipCode}</li> <li>City: TBD</li> [instruction] | Create a React component that takes a zipcode as an input and displays related information about the zipcode in a formatted way. [input] |
[output] | The modified code checks if the value of the variable x is equal to 10. If it is, it adds 10 to x, otherwise it subtracts 10. So the value of x will now be 20 if it was 10 initially, or 0 if it was not. [instruction] | Analyze the following modified code and explain what the modified code does [input] | int x = 10; if (x == 10) x = x + 10; else x = x - 10;
[output] | from polyglot.detect import Detector sentence = "Dies ist ein Satz." detector = Detector(sentence) print(detector.language.name) # Output: German [instruction] | Use Polyglot to detect the language of the following sentence [input] | Dies ist ein Satz.
[output] | FUNCTION Sort(input) SET i to 0 WHILE i < LENGTH OF input SET max to i SET j to i + 1 WHILE j < LENGTH OF input IF input[j] > input[max] THEN SET max to j END IF SET j to j + 1 END WHILE IF max != i THEN SWAP input[i] with input[max] END IF [instruction] | Write Pseudocode for a simple sorting algorithm that sorts an input array. [input] | [3, 5, 8, 2, 7]
[output] | import requests data = { "id": "123456", "name": "John Doe" } url = "http://example.com/update-user-name" response = requests.post(url, json=data) [instruction] | Write a POST request to update a user's name in the following JSON format. [input] | { "id": "123456", "name": "John Doe" }
[output] | import re string = "This is a string with multiple words and special characters !@#" matches = re.findall(r'(?<= ).*?(?= )', string) print(matches) # Output: ['is', 'a', 'string', 'with', 'multiple', 'words', 'and', 'special'] [instruction] | Use regex to extract specific words between two delimiters in a sentence. [input] | string = "This is a string with multiple words and special characters !@#"
[output] | x = 5 y = 7 z = 8 result = (x + y) * z print(result) # Output: 75 [instruction] | Evaluate this code and output the result. [input] | x = 5 y = 7 z = 8
[output] | SELECT title FROM movies WHERE year = 2000; [instruction] | Build a relational database using SQL and answer the following query: "return the titles of all movies released in the year 2000." [input] |
[output] | import tkinter as tk root = tk.Tk() frame = tk.Frame(root) frame.pack() label = tk.Label(frame, text="Hello World!") label.pack() button = tk.Button(frame, text="Exit", command=frame.quit) button.pack() root.mainloop() [instruction] | Create a Tkinter app with a label and a button. [input] |
[output] | def multiply_int(x, y): return x * y [instruction] | Create a function that returns the product of two integers. [input] |
[output] | import tensorflow as tf model = tf.keras.Sequential() model.add(tf.keras.layers.Conv2D(32, 3, activation="relu", input_shape=(28, 28, 1))) model.add(tf.keras.layers.Flatten()) model.add(tf.keras.layers.Dense(64, activation="relu")) model.add(tf.keras.layers.Dense(3, activation="softmax")) model.co [instruction] | Build a convolution neural network using tensorflow that takes a single input and classify it into one of three categories. [input] |
[output] | UPDATE employee_info SET salary = (salary * 0.95) [instruction] | Write a SQL query to minmize the output of employee salaries without firing them. [input] | TABLE employee_info ( emp_ID INT PRIMARY KEY, emp_name VARCHAR, salary int )
[output] | def filter_array(arr, num): return [x for x in arr if x > num] [instruction] | Create a function that filters an array for all numbers greater than the given number. [input] |