[output] | $sql = "CREATE TABLE mytable ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(15) )"; [instruction] | Write a PHP statement to create a MySQL table with four columns: id, name, age, gender. [input] |
[output] | SELECT name FROM customers WHERE city = 'Tokyo' AND age > 25 [instruction] | Write a SQL query to select customer names whose city is Tokyo and age is greater than 25. [input] | TABLE customers Columns: customer_id name city age
[output] | public class Car { private String color; private String make; public Car(String color, String make) { this.color = color; this.make = make; } public String getColor() { return color; } public String getMake() { return make; } } [instruction] | Create a class in Java representing a car with two attributes, color and make. [input] |
[output] | my_object = { "Name": "John", "Age": 35 } [instruction] | Construct an object in JavaScript with the following format: {"Name": "John", "Age": 35}. [input] |
[output] | from sqlalchemy import Column, Integer, String class Foo(Base): __tablename__ = 'foo' id = Column(Integer, primary_key=True) bar = Column(String) [instruction] | Generate a class like this using SQLAlchemy. [input] | class Foo: id = Column(Integer, primary_key=True) bar = Column(String)
[output] | def filter_length(strings): new_list = [] for string in strings: if len(string) >= 2: new_list.append(string) return new_list my_list = ["Hello","Hi","How","Are","You"] print(filter_length(my_list)) [instruction] | Given a list of strings, write a function that filters out all strings that have length less than two characters. [input] | my_list = ["Hello","Hi","How","Are","You"]
[output] | <form action="authenticate.php" method="post"> Email: <input type="text" name="email" /> <br /> Password: <input type="password" name="password" /> <br /> <input type="submit" value="Submit" /> </form> [instruction] | Create an HTML form to ask the user for their email and password. [input] |
[output] | <style> #container { width: 600px; } #container div { float: left; width: 50%; } </style> <div id="container"> <div>Content for the first column</div> <div>Content for the second column</div> </div> [instruction] | Using CSS, create a simple page layout with two columns of equal width. [input] | width: 600px
[output] | let hexValues = '0123456789abcdef'; let randomHexSeq = []; for (let i = 0; i < 10; i++) { randomHexSeq.push(hexValues[Math.floor(Math.random() * hexValues.length)]); } console.log(randomHexSeq.join('')); [instruction] | Generate a pseudorandom sequence of hexadecimal numbers with length 10. [input] |
[output] | SELECT * FROM users WHERE firstname = 'John'; [instruction] | Write a query in SQL to find all users with first name "John". [input] |
[output] | <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" [instruction] | Create an Android application with a Button and a TextView. When the button is clicked, the TextView should be populated with the text "Hello, World!". [input] |
[output] | <h1 style="font-size: 16px;">This is a heading</h1> <p style="font-size: 16px;">This is a paragraph.</p> [instruction] | Edit the following HTML to make all text 16px font size. [input] | <h1>This is a heading</h1> <p>This is a paragraph.</p>
[output] | SELECT Name FROM Employees; [instruction] | Write an SQL query to get names of all employees from the Employees table [input] |
[output] | public static String intToEnglish(int input) { // create an array of string representations of numbers 1 to 19 String[] numbers1_19 = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", [instruction] | Write a Java method to convert a given integer to its equivalent English words [input] |
[output] | { "model": "Toyota Camry", "year": 2020, "color": "black" } [instruction] | Create a JSON data structure to represent a car with the following fields: model, color, and year [input] |
[output] | """ Calculate the area of a triangle """ base = 10 height = 8 # calculating the area of a triangle area = (base*height)/2 print("The area of the triangle is: {}".format(area)) [instruction] | Given a triangle, calculate its area. [input] | Base: 10 Height: 8
[output] | """ Design an algorithm to detect the pattern of spikes in an EEG """ import numpy as np def detect_spike_pattern(eeg_data): # Compute power spectrum of the EEG data power_spectra = np.abs(np.fft.rfft(eeg_data)) # Detect spikes by finding peaks in the power spectrum spikes = np.whe [instruction] | Design an algorithm to detect the pattern of spikes in an EEG. [input] |
[output] | """ Compute the hamming distance between two strings and print the result """ def calc_hamming_distance(str1, str2): # Calculate the hamming distance dist = 0 for i, j in zip(str1, str2): if i != j: dist+=1 # Print the Hamming Distance print('Hamming Distance [instruction] | Compute the hamming distance between two strings and print the result. [input] | String1: 'hello' String2: 'world'
[output] | """ Calculate the scalar product of two vectors and print the result """ # Calculate the scalar product of two vectors vector1 = [1,2,3] vector2 = [4,5,6] scalar_product = sum([x*y for x,y in zip(vector1 , vector2)]) # Print the scalar product print('Scalar Product: ', scalar_product) [instruction] | Calculate the scalar product of two vectors and print the result. [input] | Vector1: [1,2,3] Vector2: [4,5,6]
[output] | """ Generate the Fibonacci sequence of length 10 and print the result """ def get_fibonacci_sequence(length): a, b = 0, 1 # generate the Fibonacci sequence sequence = [] for _ in range(length): sequence.append(a) a, b = b, a + b # return the Fibonacci sequence [instruction] | Generate the Fibonacci sequence of length 10 and print the result. [input] |
[output] | """ Count the number of vowels in the given sentence and print the result """ # given sentence sentence = 'There is no shortcut to success' # count the vowels in the sentence vowels = 0 for char in sentence: if char in 'aeiou': vowels += 1 # Print the number of vowels print('Number of [instruction] | Count the number of vowels in the given sentence and print the result. [input] | Sentence: There is no shortcut to success
[output] | """ Construct an SQL query to list the name of all students who are taking the course ‘Data Science’ """ SELECT s.name FROM Student s, Course c, StudentCourse sc WHERE c.name = 'Data Science' AND sc.CourseId = c.Id AND sc.StudentId = s.Id [instruction] | Construct an SQL query to list the name of all students who are taking the course ‘Data Science’. [input] |
[output] | """ Write a code to update a given column using the data from another table """ # Create the UPDATE statement UPDATE Student SET CourseId = (SELECT Course.Id as CourseId FROM Course WHERE Course.Name = Student.CourseName) [instruction] | Write a code to update a given column using the data from another table. [input] | Table1: Student Table2: Course Column to be updated: Student.CourseId
[output] | """ Write a code to train a random forest classifier for a given dataset """ # import the packages from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import make_classification # Create the dataset X, y = make_classification(n_samples=100, n_features=5, n_classes=2) # Creat [instruction] | Write a code to train a random forest classifier for a given dataset. [input] | Dataset features: 5 features, 100 instances, 1000 estimators
[output] | """ Write a code to simulate Conway’s Game of Life """ import numpy as np def conways_game_of_life(state, iterations): # make a copy of the game state game_state = np.copy(state) # loop over the number of iterations for _ in range(iterations): # calculate the number of neig [instruction] | Write a code to simulate Conway’s Game of Life. [input] |
[output] | """ Suggest a strategy to reduce the memory requirement of a given application """ # Suggested strategy One strategy to reduce the memory requirement of a given application is to identify the areas where the memory is used the most and to optimize the code for those areas. Additionally, use a memo [instruction] | Suggest a strategy to reduce the memory requirement of a given application. [input] |
[output] | #include <iostream> int main() { for(int i = 0; i < 10; i++) { if(i % 2 == 0) { std::cout << i << ", "; } else { std::cout << i+1 << ", "; } } std::cout << std::endl; return 0; } [instruction] | Write an `int main()` routine to print the following sequence of numbers. [input] | 10
[output] | stringArray = ['Hello', 'Peace', 'Happiness', 'Joy', 'Love'] [instruction] | Create an array with five different strings. [input] |
[output] | for i in range(0, 10): if i == 7: break print(i) [instruction] | Construct a for-loop with a break clause. [input] |
[output] | def calculateGrade(score): if score >= 90: return "A" elif score >= 80: return "B" elif score >= 70: return "C" elif score >= 60: return "D" else: return "F" [instruction] | Generate a function to calculate the grade of a student based on their marks. [input] |