[output] | """ Add 'excellent' as the last element in this list """ sports_list = ['soccer', 'rugby', 'hockey'] # Add 'excellent' as the last element in this list sports_list.append('excellent') print(sports_list) [instruction] | Add 'excellent' as the last element in this list. [input] | sports_list = ['soccer', 'rugby', 'hockey']
[output] | """ Change the value of the second element of this list to 'cricket' """ sports_list = ['soccer', 'rugby', 'hockey'] # Change the value of the second element of this list to 'cricket' sports_list[1] = 'cricket' print(sports_list) [instruction] | Change the value of the second element of this list to 'cricket'. [input] | sports_list = ['soccer', 'rugby', 'hockey']
[output] | """ Create a python dictionary consisting of the names of the seven dwarfs and a list of their ages """ dwarfs = {"Doc": 84, "Grumpy": 67, "Happy": 76, "Sleepy": 75, "Sneezy": 71, "Dopey": 76, "Bashful": 70} print(dwarfs) [instruction] | Create a python dictionary consisting of the names of the seven dwarfs and a list of their ages. [input] |
[output] | """ Extend the range from 25 to 35 """ my_list = list(range(25, 36)) print(my_list) [instruction] | Extend the range from 25 to 35. [input] | my_list = list(range(25))
[output] | """ Delete the last three elements from this list """ my_list = [1, 4, 6, 7, 6, 8, 9] # Delete the last three elements from this list my_list = my_list[:-3] print(my_list) [instruction] | Delete the last three elements from this list. [input] | my_list = [1, 4, 6, 7, 6, 8, 9]
[output] | """ Count the length of this string """ my_string = 'Hello World!' # Count the length of this string length = len(my_string) print(length) [instruction] | Count the length of this string. [input] | my_string = 'Hello World!'
[output] | True [instruction] | Classify the following statement as an example of a Boolean expression: "2 * 3 - 5 > 11". [input] | 2 * 3 - 5 > 11
[output] | lambda x: [x for x in range(0, 11) if x % 3 == 0] [instruction] | Create a lambda function in Python that collects all the numbers between 0 and 10 that are divisible by 3. [input] |
[output] | 54 [instruction] | Compute the average of the following numbers: 45, 20, 15, 100, 75. [input] |
[output] | while (true) { //infinite loop code here } [instruction] | Write a C++ code snippet to create an infinite loop. [input] |
[output] | [2**0, 2**1, 2**2, 2**3, 2**4] [instruction] | Write a Python code snippet to generate a list of the first five powers of the number 2. [input] |
[output] | /Mary\s+had\s+a\s+little\s+lamb/ [instruction] | Write a regular expression to match the following sentence: "Mary had a little lamb". [input] |
[output] | g++ -o [filename] [filename].cpp [instruction] | Compile the following C++ code: #include <iostream> using namespace std; int main() { cout << "Hello World!"; return 0; } [input] |
[output] | <html> <body> <form> Enter Number 1: <input type="text" name="num1" /> <br /> Enter Number 2: <input type="text" name="num2" /> <br /> <input type="submit" value="Submit" /> </form> <script> function calculateSum() { let num1 = document.forms["form"]["nu [instruction] | Write a HTML form to take in two user inputs and display their sum. [input] |
[output] | model = Sequential() model.add(Dense(64, activation='relu', input_dim=100)) model.add(Conv1D(32, 3)) model.add(Dense(1, activation='sigmoid')) [instruction] | Modify the following Keras model to add one 1D convolutional layer before the last layer. [input] | model = Sequential() model.add(Dense(64, activation='relu', input_dim=100)) model.add(Dense(1, activation='sigmoid'))
[output] | function removeDuplicates(str) { let result = ''; let seen = new Set(); for (let char of str) { if (!seen.has(char)) { seen.add(char); result += char; } } return result; } [instruction] | Write a JavaScript function that takes a string as an argument and produces a new string with the duplicated characters removed. [input] |
[output] | const fruits = { apple: 'red', orange: 'orange', banana: 'yellow' }; [instruction] | Create a JavaScript dictionary object using the following data. [input] | apple: red orange: orange banana: yellow
[output] | <form> <input type="number" name="num1"> <input type="number" name="num2"> <input type="submit" value="Submit"> </form> [instruction] | Create an HTML form with two input fields to take two numbers and a submit button to submit the form. [input] |
[output] | ^Hello.* [instruction] | Write a regular expression to match a string that contains the word "Hello" at the start of the string. [input] |
[output] | def larger(num1, num2): """Takes two integers and returns the larger one. Args: num1 (int): The first integer. num2 (int): The second integer. Returns: int: The larger of the two given integers. """ return max(num1, num2) [instruction] | Create a function to take two integers and return the larger one. [input] |
[output] | query { instructors { name age address } } [instruction] | Using GraphQL, write a query to get name, age and address of all instructors in a training center. [input] |
[output] | def sumOfSquares(num1, num2): return num1**2 + num2**2 [instruction] | Implement a function, sumOfSquares, that takes two integers and calculates the sum of their squares. [input] |
[output] | import requests from bs4 import BeautifulSoup website_url = requests.get('https://twitter.com/').text soup = BeautifulSoup(website_url,'html.parser') tweets_list = [] for tweet in soup.findAll('div',{'class':'tweet'}): text = tweet.find('p',{'class':'tweet-text'}).text tweets_list.append( [instruction] | Write a web scraper using BeautifulSoup to extract a list of tweets from a site. [input] | Target site: https://twitter.com/
[output] | Sub columns_sum() Dim cell As Range Dim first_sum As Integer, second_sum As Integer For Each cell In Range("A1:A5") first_sum = first_sum + cell.Value Next cell For Each cell In Range("B1:B5") second_sum = second_sum + cell.Value Next cell Range("D3").Value = first_sum + [instruction] | Automate calculations in Excel by writing a VBA program to calculate the sum of two columns. [input] |
[output] | According to RFC 2396, the maximum length of a URL is 2048 characters. [instruction] | What is the maximum length of a URL as defined in RFC 2396? [input] |
[output] | body { background-color: #2d2d2d; color: #ffffff; } // Set the typeface body { font-family: "Open Sans", Helvetica, sans-serif; } // Create the dark mode toggle switch .dark-mode-toggle{ margin-left: 10px; } // Create a dark background for all elements * { background-color: #2d2d2d; } [instruction] | Use CSS to create a dark mode version of the following website. [input] | Link to a website: https://example.com
[output] | [ { "name": "Alice", "age": 30 }, { "name": "Bob", "age": 35 } ] [instruction] | Update the following JSON array to increment the "age" value of every user by 5 years. [input] | [ { "name": "Alice", "age": 25 }, { "name": "Bob", "age": 30 } ]
[output] | SELECT students.name FROM students WHERE EXISTS ( SELECT 1 FROM classes WHERE classes.student_id = students.id AND classes.subject IN ('math','science') GROUP BY classes.student_id HAVING COUNT(DISTINCT classes.subject) = 2 ); [instruction] | Write a MySQL query to find the names of all the students who took both math and science classes. [input] |
[output] | map(key, value) { age = value.age emit(null, age) } reduce(key, values) { total = 0 count = 0 foreach (value in values) { total = total + value count = count + 1 } avg_age = total/count emit(null, avg_age) } [instruction] | Using MapReduce, calculate the average age of the users in a given dataset. [input] |
[output] | let randomString = ''; for (let i=0;i<10;i++) { randomString += String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1)) + 97); } console.log(randomString); [instruction] | Generate a random string containing 10 lowercase alphabets using JavaScript. [input] |