[output] | Research revealed ways to optimize data structures more efficiently, leading to new resource-saving techniques. [instruction] | Edit this text to make it more concise without losing any information. [input] | The research assisted in understanding the ways in which we can better optimize our data structures. We discovered many new ways of more efficiently using the resources that we were given.
[output] | import statistics def get_stats(list): mean = statistics.mean(list) stdev = statistics.stdev(list) return mean, stdev mean, stdev = get_stats(list) print("Mean:", mean) print("Standard Deviation:", stdev) [instruction] | Write a Python function that takes a list of numbers and returns the mean and standard deviation of that list. [input] | list = [1, 2, 3, 4, 5]
[output] | <html> <table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> <th>Column 5</th> <th>Column 6</th> <th>Column 7</th> </tr> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> <td>Cell 5</td> <td>C [instruction] | Create HTML code for a table that has 7 columns and 3 rows. [input] |
[output] | SELECT COUNT(*) FROM customers WHERE state = "Texas"; [instruction] | Write a SQL query to find the number of customers with a given state. [input] | state = "Texas"
[output] | def print_even_numbers(n): for i in range (0, n+1): if i % 2 == 0: print (i) print_even_numbers(20) [instruction] | Create a Python program that prints out all even numbers between 0 and the given number n. [input] |
[output] | def create_dict(list): return dict(zip(list, list)) dict = create_dict(list) print(dict) # Output: {'a': 'a', 'b': 'b', 'c': 'c'} [instruction] | Write a Python function to create a dictionary with the given list as its keys and values. [input] | list = ["a", "b", "c"]
[output] | #!/bin/bash for i in {1..5}; do echo "Hello World" done [instruction] | Write a shell script which prints “Hello World” 5 times. [input] |
[output] | A = [1, 4, 5, 12, 3, 7, 16] even_list = [x for x in A if x % 2 == 0 ] [instruction] | Create a new list which contains even elements from the existing list A. [input] | A = [1, 4, 5, 12, 3, 7, 16]
[output] | d = {'X': 4, 'Y': 5} d2 = {k:v*v for k,v in d.items()} [instruction] | Create a dictionary which contains the product of keys and their individual values from another dictionary. [input] | d = {'X': 4, 'Y': 5}
[output] | The trapezoidal approach is a numerical integration technique of approximating the area under a curve or a function using the trapezoid rule. It uses the formula y0 + yn + 2(y1+y2+...+yn-1) and is a first-order numerical integration method that can be used to approximate a definite integral. It work [instruction] | Explain how to use trapezoidal approach for numerical integration. [input] |
[output] | A while-loop in Python is used when we need to iterate through a set of instructions or code block until a condition is met or false. It allows us to perform an operation multiple times until the condition is met. For example, we can use a while-loop to iterate and check if a certain number is prime [instruction] | When would you use a while-loop in Python? [input] |
[output] | def add(a, b): return a + b # Usage print(add(3,4)) # output: 7 [instruction] | How would you create a function in Python to add two numbers? [input] |
[output] | System.out.println(Integer.toBinaryString(n)); [instruction] | Rewrite the following instruction to print the binary value it holds. [input] | int n = 12;
[output] | public static String removeWhitespace(String str) { return str.replaceAll("\\s", ""); } [instruction] | Write a Java method to remove all whitespaces from a string [input] |
[output] | #!/bin/bash for dir in $1/* do if [ -d $dir ] then echo $(basename $dir) fi done [instruction] | Create a shell script to print out the names of the all subdirectories in given directory [input] |
[output] | #include <iostream> using namespace std; int perfectNo(int low, int high) { int sum = 0; for (int i=low; i<high; i++) { int div_sum = 0; for (int j=1; j<i; j++) if (i % j == 0) div_sum += j; if (div_sum == i && i != [instruction] | Write a C++ program to find the sum of all the perfect numbers between two given inputs. [input] |
[output] | public class DayFromDate { public static void main(String[] args) { Date date = new Date(); System.out.println("Day of the month: " + date.getDate()); } } [instruction] | Write a Java program to get the day of the month from given a Date object [input] |
[output] | Inheritance is a feature of object-oriented programming (OOP) that allows one class, known as the "parent class" or "base class", to pass its properties and methods to another class, known as the "child class" or "inherited class". This relationship between the classes allows for code reuse, as the [instruction] | Explain how inheritance works in programming. [input] |
[output] | class UserProfile: def __init__(self, username, password, email, full_name, date_of_birth, address): self.username = username self.password = password self.email = email self.full_name = full_name self.date_of_birth = date_of_birth self.address = address def update_phon [instruction] | Design a class for a user profile. [input] |
[output] | char array1[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; char array2[10]; for (int i = 0; i < 10; i++) { array2[i] = array1[i]; } [instruction] | Use the comment as a guide, replace its content with the proper code. [input] | char array1[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; char array2[10]; // TODO: copy the content of array1 to array2
[output] | function findPrimeFactors(num) { let factors = []; while (num % 2 === 0) { factors.push(2); num = num / 2; } // num must be odd at this point for (let i = 3; i <= Math.sqrt(num); i += 2) { while (num % i === 0) { factors.push(i); [instruction] | Implement a JavaScript function to find all distinct prime factors of a given number. [input] |
[output] | class User { constructor(fullName, email, address) { this.fullName = fullName; this.email = email; this.address = address; } updateName(name) { // update the user's full name this.fullName = name; } updateEmail(email) { // update the user's email address thi [instruction] | Create a class in JavaScript to encapsulate user information. [input] |
[output] | class Profile { constructor(name, email, avatar_url) { this.name = name; this.email = email; this.avatar_url = avatar_url; } updateName(name) { // update the profile's name this.name = name; } updateEmail(email) { // update the profile's email address this.e [instruction] | Edit the code to create a class for a profile. [input] | class Profile { }
[output] | <!DOCTYPE html> <html> <head> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } tr:nth-child(even) { background-color: #dddddd; } </style> </head> <body> <h2>Students' Grade [instruction] | Design a HTML page to display a table of students’ grades for a specific subject. [input] |
[output] | SELECT * FROM Employees WHERE Rating IN (SELECT MAX(Rating) FROM Reviews WHERE ReviewDate = (SELECT MAX(ReviewDate) FROM Reviews) GROUP BY EmployeeID) ORDER BY Rating DESC; [instruction] | Create a MySQL query to find the employees with the best rating during their last review. [input] |
[output] | def is_even(num): if num % 2 == 0: return True else: return False [instruction] | Design an algorithm to determine if an integer is even or odd. [input] |
[output] | <?php function Fibonacci($n){ if ($n == 0) return 0; else if ($n == 1) return 1; else return (Fibonacci($n-1) + Fibonacci($n-2)); } $n = 50; for ($i = 0; $i < $n; $i++) echo Fibonacci($i),' '; ?> [instruction] | Create a PHP script to print out Fibonacci numbers up to 50. [input] |
[output] | #include <iostream> #include <cmath> using namespace std; struct Point { double x, y, z; }; //Calculate distance between two points double distance(Point p1, Point p2) { return sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2) + pow(p2.z - p1.z, 2)*1.0); } int main() { Point p1 = {2 [instruction] | Write a C++ program to calculate the distance between two points in 3D space. [input] |
[output] | let result = array.filter(n => n % 2 == 0); [instruction] | Rewrite the following JavaScript program using ES6 syntax. [input] | let result=[]; for (let i=0;i<array.length;i++) { if (array[i]%2 == 0) { result.push(array[i]); } }
[output] | def sort_descending(nums): for i in range(len(nums)): for j in range(len(nums)): if nums[i] > nums[j]: nums[i],nums[j] = nums[j],nums[i] return nums [instruction] | Create an algorithm which is able to sort a given array of integers in descending order. [input] |