messages listlengths 2 2 | conversation_id int64 0 20k |
|---|---|
[
{
"content": "Describe how to use the following code to generate random numbers.\nimport random\n\ndef random_with_N_digits(n):\n range_start = 10**(n-1)\n range_end = (10**n)-1\n return random.randint(range_start, range_end)",
"role": "user"
},
{
"content": "// To generate random numbers u... | 700 |
[
{
"content": "Generate a Frequency Table for the following sequence of characters using Python.\n'aabbccddee'",
"role": "user"
},
{
"content": "# Create a frequency table for the given sequence\n# using Python\nfrom collections import Counter\n\nstring = 'aabbccddee'\n# create the Counter object\nfr... | 701 |
[
{
"content": "In Python, write code to identify whether a given string contains only numeric values.",
"role": "user"
},
{
"content": "# To identify whether a given string contains only numeric values in Python:\n# 1. Use the isdigit method of the str object\n# 2. Pass the given string as an argumen... | 702 |
[
{
"content": "Explain how to perform a bubble sort on a given array.",
"role": "user"
},
{
"content": "// To perform a bubble sort on a given array:\n// 1. Iterate over the array and compare adjacent elements\n// 2. If the element on the left is greater than the element on the right, swap them\n// 3... | 703 |
[
{
"content": "Write a script in JavaScript to parse an XML document.",
"role": "user"
},
{
"content": "// To parse an XML document in JavaScript:\n// 1. Use the DOMParser to load the XML document into an XML Document object\n// 2. Use the getElementsByTagName method to obtain all the elements with a... | 704 |
[
{
"content": "Describe how to use the following code to calculate the sum of all elements in an array in Java.\npublic static int calcSum(int[] arr) {\n int sum = 0;\n for (var i = 0; i < arr.length; i++) {\n sum += arr[i];\n }\n return sum;\n}",
"role": "user"
},
{
"content": "//... | 705 |
[
{
"content": "Sort the given words in lexicographical order.\napple, cat, flower, dog",
"role": "user"
},
{
"content": "apple, cat, dog, flower",
"role": "assistant"
}
] | 706 |
[
{
"content": "Write SQL code to find the names of students who are enrolled in all three classes.\nTable name: students\nColumns: student_id, name, class1, class2, class3",
"role": "user"
},
{
"content": "SELECT name\nFROM students\nWHERE class1 = 1 AND class2 = 1 AND class3 = 1;",
"role": "assi... | 707 |
[
{
"content": "Generate the Fibonacci sequence up to the 10th number.",
"role": "user"
},
{
"content": "0, 1, 1, 2, 3, 5, 8, 13, 21, 34",
"role": "assistant"
}
] | 708 |
[
{
"content": "Convert this number from decimal to binary.\n128",
"role": "user"
},
{
"content": "10000000",
"role": "assistant"
}
] | 709 |
[
{
"content": "Write a JavaScript function for reversing a string.",
"role": "user"
},
{
"content": "function reverseString(str) {\n let revStr = '';\n for(let i = str.length-1; i >= 0; i--) {\n revStr += str[i];\n }\n return revStr;\n}",
"role": "assistant"
}
] | 710 |
[
{
"content": "Identify and explain the Big O runtime complexity of this algorithm.\ndef find_sum(numbers): \n total = 0\n for num in numbers:\n total += num\n return total",
"role": "user"
},
{
"content": "O(n), where n is the number of elements in the list. This algorithm has linear... | 711 |
[
{
"content": "Create a C++ program to calculate the sum of numbers in an array.\nstd::vector<int> numbers = {1, 2, 3, 4, 5};",
"role": "user"
},
{
"content": "#include <iostream>\n#include <vector>\n \nint sumArray(std::vector<int> &nums)\n{\n int sum = 0;\n for (int num : nums) {\n sum... | 712 |
[
{
"content": "Classify the following statement.\nI must finish the project by tomorrow.",
"role": "user"
},
{
"content": "Imperative sentence.",
"role": "assistant"
}
] | 713 |
[
{
"content": "Create a class in Python that implements a stack.",
"role": "user"
},
{
"content": "class Stack: \n def __init__(self): \n self.stack = []\n\n def push(self,element): \n self.stack.append(element) \n\n def pop(self): \n return self.stack.pop()\n\n def ... | 714 |
[
{
"content": "Write an R function to calculate the mean of a numerical vector.",
"role": "user"
},
{
"content": "calc_mean <- function(x) {\n mean(x)\n}",
"role": "assistant"
}
] | 715 |
[
{
"content": "Transform the following sentence into a declarative sentence.\nDo your homework every day.",
"role": "user"
},
{
"content": "You should do your homework every day.",
"role": "assistant"
}
] | 716 |
[
{
"content": "Create a Python program to extract all unique words from a given sentence.\nThis sentence contains multiple words.",
"role": "user"
},
{
"content": "sentence_words = set(sentence.split())\nunique_words = set(word for word in sentence_words if word not in visited_words)\nprint(unique_wo... | 717 |
[
{
"content": "What is the purpose of the \"break\" keyword in C language?",
"role": "user"
},
{
"content": "The \"break\" keyword is used to immediately break out of a loop in the C programming language. It can also be used to break out of a switch statement. It is used to terminate a loop or switch... | 718 |
[
{
"content": "Create a Java program that reads two numbers from the user and prints the sum.",
"role": "user"
},
{
"content": "import java.util.Scanner;\n\npublic class Sum {\n\npublic static void main(String[] args) {\n \nScanner sc = new Scanner(System.in);\n \nSystem.out.println(\"Enter first num... | 719 |
[
{
"content": "Write a SQL query to find the highest salary of a employee in the salary table?",
"role": "user"
},
{
"content": "SELECT MAX(salary) FROM salary;",
"role": "assistant"
}
] | 720 |
[
{
"content": "What is the purpose of the \"if-else\" statement in JavaScript?",
"role": "user"
},
{
"content": "The if-else statement is a control statement in JavaScript that is used to execute a block of code if a certain condition is true, and a different block of code if the condition is false. ... | 721 |
[
{
"content": "Create a HTML page that displays the words \"Hello, World!\" in different colors.",
"role": "user"
},
{
"content": "<!DOCTYPE html>\n<html>\n<head>\n <title>Hello World Page</title>\n <style>\n h1 {\n color: red;\n }\n\n h2 {\n color: bl... | 722 |
[
{
"content": "Write a C++ program to print all prime numbers between 1 and 100.",
"role": "user"
},
{
"content": "#include<iostream> \nusing namespace std; \nint main() \n{ \n int i, j,flag; \n for (i = 2; i <= 100; i++) \n { \n flag = 0; \n for (j = 2; j <= i / 2; j++) \n { \... | 723 |
[
{
"content": "Write a SQL query that finds, in a table of employees, the names and titles of all employees who work in the Marketing department.\nTable: Employees\n\n| EmployeeID | Name | Department | Title |\n|------------|------|--------------|-------------------------|\n| 1 | Bob... | 724 |
[
{
"content": "Write a for loop in Java to print all the numbers in a given list.\nint[] list = {21, 34, 54, 77, 92};",
"role": "user"
},
{
"content": "for (int i = 0; i < list.length; i++) {\n System.out.println(list[i]);\n}",
"role": "assistant"
}
] | 725 |
[
{
"content": "Suggest a data structure to store the following data.\nNames of fruits and vegetables in an online grocery store",
"role": "user"
},
{
"content": "A HashMap could be a suitable data structure to store the names of fruits and vegetables in an online store. The keys should be the names o... | 726 |
[
{
"content": "Write a function in Python that takes in two strings and concatenates them together with a space in between.",
"role": "user"
},
{
"content": "def my_concat(string1, string2)\n return string1 + ' ' + string2",
"role": "assistant"
}
] | 727 |
[
{
"content": "Find the minimum element in an unordered array given in Python.\narr = [17, 21, 4, 7, 29, 34, 11]",
"role": "user"
},
{
"content": "min_ele = arr[0]\nfor i in range (1, len(arr)):\n if (min_ele > arr[i]):\n min_ele = arr[i] \n \nprint(\"Minimum element in array is\", min_el... | 728 |
[
{
"content": "Write a function in Java to sort a given array of numbers into ascending order.\nint[] array = {11, 7, 18, 2, 5, 8};",
"role": "user"
},
{
"content": "public static void sortAscending(int[] array) \n{ \n // Sort the array in ascending order \n Arrays.sort(array); \n \n System... | 729 |
[
{
"content": "Create a HTML page with a heading 2 of \"Operating System\".",
"role": "user"
},
{
"content": "<html>\n<head>\n <title>Operating System</title>\n</head>\n<body>\n <h2>Operating System</h2>\n\n</body>\n</html>",
"role": "assistant"
}
] | 730 |
[
{
"content": "Suggest an algorithm for finding the maximum element in an unordered array given in JavaScript.\nlet array = [9, 4, 15, 10, 6, 20];",
"role": "user"
},
{
"content": "// max is assign to 0 as a starting point\nlet max = 0;\n\nfor (let i=0; i < array.length; i++) {\n // If the current v... | 731 |
[
{
"content": "Write a function that takes a string and returns a dictionary counting each character in the string.",
"role": "user"
},
{
"content": "def character_count(str): \n res = {} \n \n for keys in str: \n res[keys] = res.get(keys, 0)+1\n \n return res",
"role": "a... | 732 |
[
{
"content": "Create a bash script that prints out \"Hello World\" five times.",
"role": "user"
},
{
"content": "#!/bin/bash\n \nfor i in `seq 1 5`;\ndo\n echo \"Hello World!\"\ndone",
"role": "assistant"
}
] | 733 |
[
{
"content": "Write a CSS style to add a yellow background to the body of a webpage.",
"role": "user"
},
{
"content": "body {\n background-color: yellow;\n}",
"role": "assistant"
}
] | 734 |
[
{
"content": "Suggest a sorting algorithm to sort the following array in descending order.\narr = [17, 21, 4, 7, 29, 34, 11]",
"role": "user"
},
{
"content": "A Bubble Sort algorithm could be used to sort the given array in descending order. This algorithm compares adjacent elements in the array and... | 735 |
[
{
"content": "Modify the following Java program to find the area of a rectangle.\npublic class Area\n{\n public static void main(String[] args)\n {\n double radius = 10;\n double area = 3.14 * radius * radius;\n\n System.out.println(\"The area of the circle = \"+area);\n }\n}",
"role": "user"
},
{
"... | 736 |
[
{
"content": "Generate a list of 10 random capital letters.",
"role": "user"
},
{
"content": "['X', 'Z', 'J', 'G', 'M', 'B', 'Y', 'Q', 'C', 'T']",
"role": "assistant"
}
] | 737 |
[
{
"content": "Convert the following string to camelCase.\nthis_string_should_be_converted_to_camelCase",
"role": "user"
},
{
"content": "thisStringShouldBeConvertedToCamelCase",
"role": "assistant"
}
] | 738 |
[
{
"content": "Merge the two lists below together.\nlist_a = [1,2,3] \nlist_b = [4,5,6]",
"role": "user"
},
{
"content": "[1, 2, 3, 4, 5, 6]",
"role": "assistant"
}
] | 739 |
[
{
"content": "Read the input text and reverse it character by character.\nThis is a sample text",
"role": "user"
},
{
"content": "txet elpmas a si sihT",
"role": "assistant"
}
] | 740 |
[
{
"content": "Create an empty set in Python and add the following items into it: \"A\", \"B\", \"C\"",
"role": "user"
},
{
"content": "mySet = {\"A\", \"B\", \"C\"}",
"role": "assistant"
}
] | 741 |
[
{
"content": "Print the following 2D matrix in row-major order.\n[[1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]]",
"role": "user"
},
{
"content": "1 4 7 2 5 8 3 6 9",
"role": "assistant"
}
] | 742 |
[
{
"content": "Create a Python dictionary with keys \"A\", \"B\", \"C\" and each key value should be the length of corresponding key.",
"role": "user"
},
{
"content": "{\"A\": 1, \"B\": 1, \"C\": 1}",
"role": "assistant"
}
] | 743 |
[
{
"content": "Generate a 3x3 matrix of random real numbers in the range of 0.0 to 1.0.",
"role": "user"
},
{
"content": "import numpy as np\nnp.random.RandomState(0).rand(3, 3)",
"role": "assistant"
}
] | 744 |
[
{
"content": "Concatenate the two strings below, with a space inserted between them.\nA = \"Hello\"\nB = \"World!\"",
"role": "user"
},
{
"content": "A + ' ' + B",
"role": "assistant"
}
] | 745 |
[
{
"content": "Calculate the average from a given list of integers.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "sum(list_of_numbers) / len(list_of_numbers)",
"role": "assistant"
}
] | 746 |
[
{
"content": "Find the sum of the elements in a given list of numbers.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "sum(list_of_numbers)",
"role": "assistant"
}
] | 747 |
[
{
"content": "Rewrite the following code into a generator.\ndef some_function(nums):\n output = []\n for x in nums:\n y = x ** 2\n output.append(y)\n return output",
"role": "user"
},
{
"content": "def some_function(nums):\n for x in nums:\n yield x ** 2",
"role": "assistant"
}
] | 748 |
[
{
"content": "In C++, search a given string for a given sub-string.\nstring = \"This is a string\"\n sub_string = \"ing\"",
"role": "user"
},
{
"content": "size_t found = string.find(sub_string);\nif (found != string::npos) {\n // sub-string found\n} else {\n // sub-string not found\n}",
... | 749 |
[
{
"content": "Write a bash script to list the content of the current directory.",
"role": "user"
},
{
"content": "#!/bin/bash\n\nls",
"role": "assistant"
}
] | 750 |
[
{
"content": "Create a JavaScript object to represent a person's name and age.",
"role": "user"
},
{
"content": "let person = {\n name: \"John Doe\",\n age: 25\n};",
"role": "assistant"
}
] | 751 |
[
{
"content": "Generate an array of odd numbers up to and including the number 10.",
"role": "user"
},
{
"content": "let numbers = [1, 3, 5, 7, 9];",
"role": "assistant"
}
] | 752 |
[
{
"content": "Create a JavaScript variable to store the current date and time.",
"role": "user"
},
{
"content": "let datetime = new Date();",
"role": "assistant"
}
] | 753 |
[
{
"content": "Write a Python function to count the letters in a given sentence and return a dictionary of letter counts.\nsentence = \"Hello World!\"",
"role": "user"
},
{
"content": "def letter_counts(sentence):\n count_dict = {}\n for char in sentence:\n if char.isalpha():\n if char in c... | 754 |
[
{
"content": "Suggest a syntax to create a PHP class for a user.",
"role": "user"
},
{
"content": "class User {\n public $name;\n public $age;\n\n function __construct($name, $age) {\n $this->name = $name;\n $this->age = $age;\n }\n}",
"role": "assistant"
}
] | 755 |
[
{
"content": "Create a SQL query to find the average salary of all employees in the department labeled \"sales\".",
"role": "user"
},
{
"content": "SELECT AVG(salary) \nFROM Employees \nWHERE department = 'sales';",
"role": "assistant"
}
] | 756 |
[
{
"content": "Write a CSS selector to apply a font-size of 16px to every element with a class of \"heading\".",
"role": "user"
},
{
"content": ".heading {\n font-size: 16px;\n}",
"role": "assistant"
}
] | 757 |
[
{
"content": "Generate a 5-element tuple of random numbers between 5 and 15 using Python.",
"role": "user"
},
{
"content": "import random\n\nrandom_tuple = tuple(random.randint(5, 15) for _ in range(5))",
"role": "assistant"
}
] | 758 |
[
{
"content": "Edit the following HTML code to add an additional radio button with the label \"orange\".\n<input type=\"radio\" name=\"fruit\" value=\"apple\"> Apple<br>\n<input type=\"radio\" name=\"fruit\" value=\"banana\"> Banana",
"role": "user"
},
{
"content": "<input type=\"radio\" name=\"fruit... | 759 |
[
{
"content": "Write a function in Python to check if two strings are an anagram or not.",
"role": "user"
},
{
"content": "def is_anagram(str1, str2): \n if len(str1) != len(str2): \n return False \n \n s1 = sorted(str1) \n s2 = sorted(str2) \n \n if s1 == s2: \n return Tr... | 760 |
[
{
"content": "Analyze the given Java code and identify the errors.\npublic class TestClass {\n public static void main (String[] args) {\n int x = 10;\n int y = 20\n int z = x + y;\n system.out.println(\"The sum is: \" + z);\n }\n}",
"role": "user"
},
{
"content": "The errors... | 761 |
[
{
"content": "Create a new MySQL table to store user data.\nTable structure: \nUser_ID, FirstName, LastName, Email",
"role": "user"
},
{
"content": "CREATE TABLE User_Data (\nUser_ID INT,\nFirstName VARCHAR (20) NOT NULL,\nLastName VARCHAR (20) NOT NULL,\nEmail VARCHAR (50) NOT NULL,\n PRIMARY KEY (... | 762 |
[
{
"content": "Create a Python program to generate a random string of 5 characters.",
"role": "user"
},
{
"content": "import random\n\ndef generate_random_string():\n characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n random_string = ''\n for x in range(5):\n random... | 763 |
[
{
"content": "Manipulate the given list in Python to include the new element at the beginning.\nlist = [1, 2, 3]\nnew_element = 0",
"role": "user"
},
{
"content": "list = [0] + list \nlist.insert(0, new_element)",
"role": "assistant"
}
] | 764 |
[
{
"content": "Write a query in SQL to list the employee information from the given Employee table in descending order of their salaries.\nTable structure:\nEmployee_ID Name Department Salary",
"role": "user"
},
{
"content": "SELECT * FROM Employee \nORDER BY Salary DESC;",
"role": "assistan... | 765 |
[
{
"content": "Write an HTML page including the given text.\nThis is a test page",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>Test Page</title>\n </head>\n <body>\n <h1>This is a test page</h1>\n </body>\n</html>",
"role": "assistant"
}
] | 766 |
[
{
"content": "Find the average salary of the given table.\nTable structure:\nEmployee_ID Name Department Salary",
"role": "user"
},
{
"content": "SELECT AVG (Salary) \nFROM Employee ;",
"role": "assistant"
}
] | 767 |
[
{
"content": "Write a SQL query to select the row with the customer id \"CID001\" from the customers table.",
"role": "user"
},
{
"content": "SELECT * FROM customers WHERE customer_id = 'CID001';",
"role": "assistant"
}
] | 768 |
[
{
"content": "Create a CSS rule to make all h1 elements red in color.",
"role": "user"
},
{
"content": "h1 {\n color: red;\n}",
"role": "assistant"
}
] | 769 |
[
{
"content": "Identify the most efficient data structure to store a list of strings.",
"role": "user"
},
{
"content": "A linked list is the most efficient data structure for storing a list of strings, as it offers constant-time insertions and deletions.",
"role": "assistant"
}
] | 770 |
[
{
"content": "Using the code below, update the function to find the average of two numbers.\ndef find_average(num1, num2): \n total = num1 + num2",
"role": "user"
},
{
"content": "def find_average(num1, num2): \n total = num1 + num2 \n average = total / 2\n return average",
"role": "assistan... | 771 |
[
{
"content": "Write a JavaScript code snippet to center text in a div element with id \"myDiv\".",
"role": "user"
},
{
"content": "document.getElementById('myDiv').style.textAlign = \"center\";",
"role": "assistant"
}
] | 772 |
[
{
"content": "Generate a random string with 10 characters.",
"role": "user"
},
{
"content": "let randomString = Math.random().toString(36).substring(2, 12);",
"role": "assistant"
}
] | 773 |
[
{
"content": "Write a Python code to print \"Hello World!\" on the console.",
"role": "user"
},
{
"content": "print(\"Hello World!\")",
"role": "assistant"
}
] | 774 |
[
{
"content": "Create a list of car models that includes \"Honda Accord\", \"Toyota Corolla\", and \"Ford F150\".",
"role": "user"
},
{
"content": "car_models = [\"Honda Accord\", \"Toyota Corolla\", \"Ford F150\"]",
"role": "assistant"
}
] | 775 |
[
{
"content": "Write a JavaScript code to add two numbers using a prompt.",
"role": "user"
},
{
"content": "let a = prompt('Enter the first number:');\nlet b = prompt('Enter the second number:');\nlet sum = parseInt(a) + parseInt(b);\nconsole.log(sum);",
"role": "assistant"
}
] | 776 |
[
{
"content": "Using the provided HTML, add a class attribute to the h1 tag so its style can be updated.\n<h1>My Website</h1>",
"role": "user"
},
{
"content": "<h1 class=\"myClass\">My Website</h1>",
"role": "assistant"
}
] | 777 |
[
{
"content": "Create a dictionary of fruits and their respective colors.",
"role": "user"
},
{
"content": "fruits = {\n \"apple\": \"red\",\n \"banana\": \"yellow\",\n \"grape\": \"purple\"\n}",
"role": "assistant"
}
] | 778 |
[
{
"content": "Edit the provided CSS rule to make all elements with the class \"myClass\" have a bold font-weight.\n.myClass { \n font-size: 16px;\n}",
"role": "user"
},
{
"content": ".myClass { \n font-size: 16px;\n font-weight: bold;\n}",
"role": "assistant"
}
] | 779 |
[
{
"content": "Create a class to represent a two-dimensional vector.",
"role": "user"
},
{
"content": "class Vector2D(object):\n '''Class to represent a two-dimensional vector'''\n def __init__(self, x, y):\n self.x = x\n self.y = y\n \n def __add__(self, other):\n return Vector2D(self.x... | 780 |
[
{
"content": "Compare the performance of Grover's algorithm and classical search algorithms.",
"role": "user"
},
{
"content": "Grover's algorithm is a quantum algorithm that offers exponential speedup over classical search algorithms. As an example of how it works, assume we want to find an element ... | 781 |
[
{
"content": "Implement a linked list in Python.",
"role": "user"
},
{
"content": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n def __init__(self):\n self.head = None\n\n def insert_at_head(self, data):\n ne... | 782 |
[
{
"content": "Create a Java 8 Stream to filter a list of objects by a given field.\n[\n {'name': 'John', 'age': 20},\n {'name': 'Smith', 'age': 30},\n {'name': 'Bill', 'age': 40}\n]",
"role": "user"
},
{
"content": "List<Object> list = Arrays.asList({\n {'name': 'John', 'age': 20},\n ... | 783 |
[
{
"content": "Identify a potential bug in the following code.\ndef add(a, b):\n c = a + b\n return c",
"role": "user"
},
{
"content": "A potential bug in this code is that if the parameters a and b are passed in as strings instead of numbers, then the resulting c will be a concatenation of the... | 784 |
[
{
"content": "Edit this JavaScript code to use the correct syntax for the switch statement.\nif (action == 'play') {\n console.log('Playing...');\n} else if (action == 'stop') {\n console.log('Stopping...');\n} else {\n console.log('Undefined action');\n}",
"role": "user"
},
{
"content": "switch ... | 785 |
[
{
"content": "Explain what a Turing machine is.",
"role": "user"
},
{
"content": "A Turing machine is a mathematical model of computation that was initially developed by Alan Turing in 1936. It is a device that can read and write symbols on a strip of tape according to a set of instructions. The tap... | 786 |
[
{
"content": "Format this JSON data as per a specific schema.\n{\n \"name\": \"John\",\n \"age\": 20,\n \"height_cm\": 178,\n \"weight_kg\": 73\n}",
"role": "user"
},
{
"content": "{\n \"name\": \"John\",\n \"age\": 20,\n \"info\": {\n \"height_cm\": 178,\n \"weigh... | 787 |
[
{
"content": "What is the purpose of an abstract data type in software engineering?",
"role": "user"
},
{
"content": "The purpose of an abstract data type in software engineering is to allow for the creation of data structures which have a certain behavior, without having to specify exactly how the ... | 788 |
[
{
"content": "What is the primary purpose of object-oriented programming?",
"role": "user"
},
{
"content": "The primary purpose of object-oriented programming is to create software systems that are modular, reusable, and maintainable. By modeling real-world objects and their behavior as individual c... | 789 |
[
{
"content": "Design a class in Java that can store student information.",
"role": "user"
},
{
"content": "public class Student {\n private String name;\n private int age;\n private String course;\n\n public Student(String name, int age, String course) {\n this.name = name;\n this.age = ag... | 790 |
[
{
"content": "Create a class in Java that can store a list of students and the courses they are enrolled in.",
"role": "user"
},
{
"content": "public class StudentList {\n private ArrayList<Student> students;\n private ArrayList<String> courses;\n\n public StudentList() {\n this.students = new... | 791 |
[
{
"content": "Write an SQL query to select the names of all employees from the table 'employees' with an age greater than 25.",
"role": "user"
},
{
"content": "SELECT name FROM employees WHERE age > 25;",
"role": "assistant"
}
] | 792 |
[
{
"content": "Change the variable names in the following Python code.\nx1 = 10\ny1 = 20",
"role": "user"
},
{
"content": "a = 10\nb = 20",
"role": "assistant"
}
] | 793 |
[
{
"content": "Design a class in Java that can store a list of books and their associated authors.",
"role": "user"
},
{
"content": "public class BookCollection {\n private ArrayList<Book> books;\n private ArrayList<String> authors;\n\n public BookCollection() {\n this.books = new ArrayList<Boo... | 794 |
[
{
"content": "Create an HTML form with three text fields—name, age and gender.",
"role": "user"
},
{
"content": "<form>\n <label for=\"name\">Name:</label>\n <input type=\"text\" id=\"name\" name=\"name\">\n <br>\n <label for=\"age\">Age:</label>\n <input type=\"text\" id=\"age\" name=\"age\">\n <br... | 795 |
[
{
"content": "Edit the following JavaScript code to reverse the characters of a given string.",
"role": "user"
},
{
"content": "function reverseString(string) {\n let reversedString = \"\";\n for (let i = string.length - 1; i >= 0; i--) {\n reversedString += string[i];\n }\n return reversedSt... | 796 |
[
{
"content": "Fix the Python code below to make the script work.\nimport json\n\ndata = {\n \"name\": \"John Doe\",\n \"age\": 20\n}\n\nwith open(\"data.txt\", \"w\") as outfile:\n json.dump(data, outfile)",
"role": "user"
},
{
"content": "import json\n\ndata = {\n \"name\": \"John Doe\",\n \... | 797 |
[
{
"content": "Compile a C program to print the number of arguments passed.\n#include <stdio.h>\n\nint main(int argc, char *argv[]) {\n printf(\"number of arguments passed: %d\\n\", argc);\n return 0;\n}",
"role": "user"
},
{
"content": "gcc -o program program.c",
"role": "assistant"
}
] | 798 |
[
{
"content": "Build a linear regression model using Python's scikit learn library.\nimport pandas as pd\nimport numpy as np\n\ndata = pd.DataFrame({\n 'x': [2.5, 0.5, 2.2, 1.9, 3.1, 2.3, 2, 1, 1.5, 1.1],\n 'y': [2.4, 0.7, 2.9, 2.2, 3, 2.7, 1.6, 1.1, 1.6, 0.9]\n })\n\nX = data['x'].values.reshape(-1, 1)... | 799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.