messages listlengths 2 2 | conversation_id int64 0 20k |
|---|---|
[
{
"content": "Develop a Java program to check if an input number is an Armstrong number.",
"role": "user"
},
{
"content": "public class ArmstrongNumber {\n \tpublic static void main(String[] args) {\n \t\tint number = 407; \n \t\t// sample input\n \n \t\t// calculate the length of the number\n \t\ti... | 19,900 |
[
{
"content": "Design a program to generate prime numbers between 1 and 50.",
"role": "user"
},
{
"content": "# Program to print the prime numbers between 1 and 50\n \nfor num in range(1, 51):\n\n # prime numbers are greater than 1\n if num > 1:\n for i in range(2, num):\n if (num... | 19,901 |
[
{
"content": "Generate a for loop in Java for printing integers from 0 to 10.",
"role": "user"
},
{
"content": "for (int i = 0; i <= 10; i++) {\n System.out.println(i);\n}",
"role": "assistant"
}
] | 19,902 |
[
{
"content": "Create a procedure in C# to print a string.\nmy_string",
"role": "user"
},
{
"content": "void PrintString(string my_string) {\n Console.WriteLine(my_string);\n}\n\nPrintString(\"my_string\");",
"role": "assistant"
}
] | 19,903 |
[
{
"content": "Design an SQL query for displaying the names and ages of all employees.\nEmployee table with the columns \"name\" and \"age\"",
"role": "user"
},
{
"content": "SELECT name, age FROM Employee;",
"role": "assistant"
}
] | 19,904 |
[
{
"content": "Boil down a JavaScript object into an array of key-value pairs.\nobject = {a: 1, b: 2, c: 3}",
"role": "user"
},
{
"content": "const kvPairs = Object.entries(object);\n// [['a', 1], ['b', 2], ['c', 3]]",
"role": "assistant"
}
] | 19,905 |
[
{
"content": "Construct a for loop in C# for picking out numbers that are divisible by 3.\nnumbers = [1, 2, 3, 4, 5, 6, 7]",
"role": "user"
},
{
"content": "foreach (int num in numbers) {\n if (num % 3 == 0) {\n Console.WriteLine(num);\n }\n}",
"role": "assistant"
}
] | 19,906 |
[
{
"content": "Write a SQL query for listing students who are 18 years old.\nStudent table with the columns \"name\" and \"age\"",
"role": "user"
},
{
"content": "SELECT name FROM Student WHERE age = 18;",
"role": "assistant"
}
] | 19,907 |
[
{
"content": "Design a function in Python for computing the multiplication of 3 numbers.\n4, 5, 6",
"role": "user"
},
{
"content": "def multiply_three(a, b, c):\n return a * b * c\n\nmultiply_three(4, 5, 6) # returns 120",
"role": "assistant"
}
] | 19,908 |
[
{
"content": "Develop a JavaScript object for storing the name and occupation of an employee.\nname = 'John Doe', occupation = 'Programmer'",
"role": "user"
},
{
"content": "const employee = {\n name: 'John Doe',\n occupation: 'Programmer'\n}",
"role": "assistant"
}
] | 19,909 |
[
{
"content": "Make an SQL query for calculating the average salary of employees.\nEmployee table with the column \"salary\"",
"role": "user"
},
{
"content": "SELECT AVG(salary) FROM Employee;",
"role": "assistant"
}
] | 19,910 |
[
{
"content": "Write code in Python to calculate the area of a triangle given 3 sides.\nside1 = 12\nside2 = 15\nside3 = 10",
"role": "user"
},
{
"content": "def areaTriangle( side1, side2, side3): \n # calculate the semi-perimeter \n s = (side1 + side2 + side3) / 2\n \n # calculate the ar... | 19,911 |
[
{
"content": "Write a script in Python that can classify a sentence as positive or negative.\nThe movie was terrible and boring.",
"role": "user"
},
{
"content": "import nltk\nfrom nltk.sentiment import SentimentIntensityAnalyzer\n\nsentence = \"The movie was terrible and boring.\"\nanalysis = Senti... | 19,912 |
[
{
"content": "Write a function in C that minimizes the cost of a given parameter using gradient descent.\nThe parameter is w(t+1) = w(t) - alpha * Le(w)\nHere, alpha= 0.3 and Le(w) = 14w^2 + 8 * w - 7",
"role": "user"
},
{
"content": "#include<stdio.h>\n \n//Function to calculate L(w)\ndouble Fun(do... | 19,913 |
[
{
"content": "Edit the given C program to print the output in a tabular form using printf.\n#include<stdio.h>\n \nint main(){\n \n int n=5;\n int i;\n int arr[n];\n \n //Adding elements in array\n for(i=0;i<n;i++){\n arr[i] = i + 20;\n }\n \n //Printing elements in array\n for(i=0;i<... | 19,914 |
[
{
"content": "Write a SQL code to generate a new table called \"Customers\" by selecting all columns from the \"Orders\" table.",
"role": "user"
},
{
"content": "SELECT *\nINTO Customers\nFROM Orders;",
"role": "assistant"
}
] | 19,915 |
[
{
"content": "Edit the given Bash script to output only the lines with double digit numbers.\n#!/bin/bash\nnumlist=\"25 3 1 2 46 4 5 21 7 9 6 10\"\nfor i in $numlist\ndo\n echo \"Number $i\"\ndone",
"role": "user"
},
{
"content": "#!/bin/bash\nnumlist=\"25 3 1 2 46 4 5 21 7 9 6 10\"\nfor i in $nu... | 19,916 |
[
{
"content": "Write an R program to generate a frequency table for the given data.\ndata <- c(\"A\", \"B\", \"C\", \"A\", \"A\", \"B\", \"E\", \"C\", \"A\", \"B\")",
"role": "user"
},
{
"content": "# Create a vector\ndata <- c(\"A\", \"B\", \"C\", \"A\", \"A\", \"B\", \"E\", \"C\", \"A\", \"B\")\n\n... | 19,917 |
[
{
"content": "Combine the following two commands into a single shell script.\necho \"FileName: File1\"\ncat File1.txt",
"role": "user"
},
{
"content": "#!/bin/bash\necho \"FileName: File1\"\ncat File1.txt",
"role": "assistant"
}
] | 19,918 |
[
{
"content": "Create an API by combining the given HTML and JavaScript code.\n<!DOCTYPE html>\n<html>\n<head>\n <title>Test API</title>\n</head>\n\n<body>\n\n<div id=\"output\"></div>\n\n<script> \n let name = \"John\"; \n document.getElementById(\"output\").innerHTML = `Hello, ${name}`;\n</script>\n\n</bod... | 19,919 |
[
{
"content": "Write a Node.js code to call an API and print the output.",
"role": "user"
},
{
"content": "const request = require('request'); \n \n// Print the output of the api\nrequest('https://example.com/api', { json: true }, (err, res, body) => { \n if (err) { \n return console.log(err); \... | 19,920 |
[
{
"content": "Design a program to search for a given string within an array of strings.\narr = ['hello', 'world', 'how', 'are', 'you']\ngiven_str = 'how'",
"role": "user"
},
{
"content": "def search(arr, given_str):\n for item in arr:\n if item == given_str:\n return True\n r... | 19,921 |
[
{
"content": "Write a function to remove a given element from an array of integers.\narr = [2, 3, 4, 5, 6]\nremove_element = 4",
"role": "user"
},
{
"content": "def remove_element(arr, remove_element):\n new_arr = []\n for item in arr:\n if item != remove_element: \n new_arr.... | 19,922 |
[
{
"content": "What is the cosine similarity between two vectors?",
"role": "user"
},
{
"content": "Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space that measures the cosine of the angle between them. It is a normalized measure of similarity, ranging... | 19,923 |
[
{
"content": "Write Python code to group list elements into sublists of particular length.\n[1,2,3,4,5,6,7,8]",
"role": "user"
},
{
"content": "def group_by_length(arr, k): \n\tn = len(arr)\n\tgroups = [arr[i:i+k] for i in range(0, n, k)] \n\treturn groups\n\na = [1,2,3,4,5,6,7,8] \nk = 3\nprint(gro... | 19,924 |
[
{
"content": "Write a JavaScript code to print the pyramid pattern for a given number of rows.\n7",
"role": "user"
},
{
"content": "function pyramid(n) { \n for (let i = 0; i < n; i++) { \n let str = ''; \n for (let j = 0; j < n-i; j++) { \n str = str + ' '; \n } \n for (let... | 19,925 |
[
{
"content": "Create a program in JavaScript to edit the existing string by replacing some of its character.\nstring = \"Hello world!\"\nreplacement = \"Bye world!\"",
"role": "user"
},
{
"content": "let str = \"Hello world!\";\n\nlet changedStr = str.replace(\"Hello\", \"Bye\");\nconsole.log(change... | 19,926 |
[
{
"content": "Draft a pseudo-code to implement a linear search algorithm in an array.",
"role": "user"
},
{
"content": "ALGORITHM LinearSearch(arr, value)\n SET i = 0\n WHILE i < arr.length\n IF arr[i] == value\n RETURN i\n ELSE \n SET i = i + 1\n RETURN ... | 19,927 |
[
{
"content": "Write an outbound rule in Firewall to block traffic from a certain IP address.\nIP address: 123.123.123.123",
"role": "user"
},
{
"content": "sudo iptables -A OUTPUT -s 123.123.123.123 -j DROP",
"role": "assistant"
}
] | 19,928 |
[
{
"content": "Determine the angle of the triangle given its three sides.\na = 5, b = 6, c = 7",
"role": "user"
},
{
"content": "The angle between side a and b is 53.13°.",
"role": "assistant"
}
] | 19,929 |
[
{
"content": "Create a function that returns the evaluation metric of a model.",
"role": "user"
},
{
"content": "def Evaluate(model):\n metrics = model.evaluate()\n return metrics",
"role": "assistant"
}
] | 19,930 |
[
{
"content": "Retrieve data from an SQL database.\nTable name: users",
"role": "user"
},
{
"content": "SELECT * FROM users;",
"role": "assistant"
}
] | 19,931 |
[
{
"content": "Replace all occurrences of one character with another in a given string.\nstring: Hello there\ncharacters: 'o' and 'a'",
"role": "user"
},
{
"content": "Hella there",
"role": "assistant"
}
] | 19,932 |
[
{
"content": "Convert a number from decimal to octal in Python.\nnumber = 109",
"role": "user"
},
{
"content": "decimal = 109 \noctal = format(decimal, 'o') \n\nprint(\"Decimal:\", decimal)\nprint(\"Octal:\", octal)",
"role": "assistant"
}
] | 19,933 |
[
{
"content": "Write a JavaScript expression to generate a random integer between 1 and 25.",
"role": "user"
},
{
"content": "var randNumber = Math.floor(Math.random() * 25) + 1;",
"role": "assistant"
}
] | 19,934 |
[
{
"content": "Write a SQL query to extract all the orders placed on a given date.\norder_date = \"2020-01-01\"",
"role": "user"
},
{
"content": "SELECT * \nFROM orders \nWHERE order_date = '2020-01-01';",
"role": "assistant"
}
] | 19,935 |
[
{
"content": "Write a function in JavaScript that takes 2 parameters of type string and concatenates them.\nparam1 = \"hello\"\nparam2 = \"world\"",
"role": "user"
},
{
"content": "function concatenate(str1, str2){\n return str1 + str2;\n}\n\nconsole.log(concatenate(param1,param2)); // \"helloworld... | 19,936 |
[
{
"content": "Create a list comprehension that finds all elements that are divisible by 3 in a given list.\nnumbers =[1, 5, 8, 10, 15, 20]",
"role": "user"
},
{
"content": "def divisible_by_three(numbers):\n res = [num for num in numbers if num % 3 == 0]\n return res",
"role": "assistant"
... | 19,937 |
[
{
"content": "Modify the code so that it checks if the number input is an integer or a decimal.\nnumber = input(\"Please input a number: \")",
"role": "user"
},
{
"content": "number = input(\"Please input a number: \")\n\nif type(number) == int:\n print(\"Input is an integer\")\nelse:\n print(... | 19,938 |
[
{
"content": "Create a function that creates a tuple of the given arguments and returns the tuple.\na=\"A\"\nb=\"B\"",
"role": "user"
},
{
"content": "def create_tuple(a, b):\n return (a, b)",
"role": "assistant"
}
] | 19,939 |
[
{
"content": "Create a loop that prints out the numbers from 30 to 0, going in reverse.",
"role": "user"
},
{
"content": "for i in range(30, -1, -1):\n print(i)",
"role": "assistant"
}
] | 19,940 |
[
{
"content": "Define a class named 'Employee' that stores the ID, name, and age of a person.",
"role": "user"
},
{
"content": "class Employee:\n def __init__(self, ID, name, age):\n self.ID = ID\n self.name = name\n self.age = age\n \n def get_info(self):\n return (... | 19,941 |
[
{
"content": "Write a function that takes two strings as parameters and returns whether they are an anagram of each other or not.\nstring1 = \"abcde\"\n\nstring2 = \"edcba\"",
"role": "user"
},
{
"content": "def is_anagram(string1, string2):\n if sorted(string1) == sorted(string2):\n retur... | 19,942 |
[
{
"content": "Modify the following function to only take numbers greater than 10.\ndef filter(numbers):\n return [n for n in numbers if n % 2 == 0]\n\nnumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"role": "user"
},
{
"content": "def filter(numbers):\n return [n for n in numbers if n > 10 and n %... | 19,943 |
[
{
"content": "Write a function that takes a numerical parameter and returns True if it is positive and False if it is negative.",
"role": "user"
},
{
"content": "def is_positive(num):\n if num > 0:\n return True\n else:\n return False\n\nif __name__ == '__main__':\n num = 5\n ... | 19,944 |
[
{
"content": "Edit the following code to make it generate a random number between 1 and 10.\nimport random\n\ndef generate_random_number():\n return random.randint(0, 11)",
"role": "user"
},
{
"content": "import random\n\ndef generate_random_number():\n return random.randint(1, 10)",
"role... | 19,945 |
[
{
"content": "Write a function that takes a list of strings and counts the number of each string that contains the letter \"a\".\n['foo', 'bar', 'baz']",
"role": "user"
},
{
"content": "def count_words_with_letter_a(arr):\n count = 0\n for s in arr:\n if 'a' in s:\n count += ... | 19,946 |
[
{
"content": "Reverse the following list of numbers.\n[1, 2, 3, 4]",
"role": "user"
},
{
"content": "def reverse_list(nums):\n return nums[::-1]\n\nif __name__ == '__main__':\n numbers = [1, 2, 3, 4]\n reversed_list = reverse_list(numbers)\n print(reversed_list)",
"role": "assistant"... | 19,947 |
[
{
"content": "Build a HTML page using the given CSS class\nCSS Classes:\n\n.container {\n width: 300px;\n height: 200px;\n background-color: blue;\n}\n\n.text {\n color: white;\n font-family: Arial;\n font-size: 16px;\n padding: 15px;\n text-align: center;\n}",
"role": "user"
},
... | 19,948 |
[
{
"content": "Construct a SQL query to identify the sum contained in the column \"Price\" from the table \"Orders\".\nTable: Orders\nColumn: Price",
"role": "user"
},
{
"content": "SELECT SUM(Price) FROM Orders;",
"role": "assistant"
}
] | 19,949 |
[
{
"content": "Construct a function to convert currency amount from USD to INR.\nCurrent USD to INR ratio: 1 USD = 73.20 INR",
"role": "user"
},
{
"content": "def currency_convert(amount):\n \n #Convert amount from USD to INR\n inr = amount * 73.20 \n \n #return the converted currency\n... | 19,950 |
[
{
"content": "Construct a SQL query to find all first names from the table \"Employees\" beginning with \"J\".\nTable: Employees\nColumn: First_Name",
"role": "user"
},
{
"content": "SELECT First_Name FROM Employees WHERE First_Name LIKE 'J%';",
"role": "assistant"
}
] | 19,951 |
[
{
"content": "Update the given Python program to reverse a string.\ndef reverse_string(s): \n #insert code here\n return s",
"role": "user"
},
{
"content": "def reverse_string(s):\n return s[::-1]",
"role": "assistant"
}
] | 19,952 |
[
{
"content": "Construct a function to check for an anagram in Python.",
"role": "user"
},
{
"content": "def anagram_check(s1, s2):\n s1 = s1.replace(' ','').lower()\n s2 = s2.replace(' ','').lower()\n \n if(sort(s1) == sort(s2)):\n return True\n \n return False\n \ndef so... | 19,953 |
[
{
"content": "Develop an R program that returns the node of a linked list.",
"role": "user"
},
{
"content": "# Defining a node \nNode <- function(value){\t \n this$value <- value\n this$next <- NULL\n return(this)\n} \n\t\n# Defining a Linked List \nLinkedList <- function(){ \n this$head <- ... | 19,954 |
[
{
"content": "Implement a matrix multiplication program in Java.",
"role": "user"
},
{
"content": "public class MatrixMultiplication \n{\n static int N = 5; \n \n static int[][] multiply(int[][] A, \n int[][] B) \n { \n int[][] C = new int[N][N]; \n \n f... | 19,955 |
[
{
"content": "Build a CNN model in Keras to detect cancer from a provided dataset.",
"role": "user"
},
{
"content": "# Importing the libraries\nfrom keras.models import Sequential\nfrom keras.layers import Conv2D\nfrom keras.layers import MaxPooling2D\nfrom keras.layers import Flatten\nfrom keras.la... | 19,956 |
[
{
"content": "Develop a code in R that returns the maximum from a list.",
"role": "user"
},
{
"content": "#function to return maximum\nmax <- function(x)\n{\n max_num <- 0 #Initialize maximum number\n for (i in x)\n {\n if (i > max_num)\n {\n max_num <- i\n }\n }\n return (max_num... | 19,957 |
[
{
"content": "Create a SQL query to select the name, job title and salary of all employees who work in the Sales department.",
"role": "user"
},
{
"content": "SELECT name, job_title, salary\nFROM employees\nWHERE department = 'Sales'",
"role": "assistant"
}
] | 19,958 |
[
{
"content": "Create an example of a deep learning neural network in Keras.",
"role": "user"
},
{
"content": "\"\"\"\nExample of a deep learning neural network in Keras\n\"\"\"\n\nimport keras\nfrom keras.models import Sequential\nfrom keras.layers import Dense\n\n#Create a Sequential model\nmodel =... | 19,959 |
[
{
"content": "Explain the purpose of each line of code in the following program.\n\"\"\"\ndef fun(x):\n y = x * 2\n return y\n\"\"\"",
"role": "user"
},
{
"content": "\"\"\"\nThe first line of code defines a function named `fun` which takes a single parameter `x`.\n\nThe second line multiplies... | 19,960 |
[
{
"content": "Create an example of data visualization using Python's matplotlib library.",
"role": "user"
},
{
"content": "\"\"\"\nExample of data visualization using Python's matplotlib library\n\"\"\" \nimport matplotlib.pyplot as plt\n\n#Create two datasets\nx_values = [1, 2, 3, 4, 5]\ny_values ... | 19,961 |
[
{
"content": "Write a JavaScript function to create an array with given size and filled with the characters given in second argument.\n3, \"*\"",
"role": "user"
},
{
"content": "```\nfunction createArray(size, character) {\n let arr = []; \n for (let i = 0; i < size; i++) { \n arr[i] = ... | 19,962 |
[
{
"content": "explain the meaning of the following line of code in terms a novice programmer can understand.\narr.sort(reverse=True)",
"role": "user"
},
{
"content": "This line of code will sort the array `arr` in descending order. That is, the array's elements will be arranged in a descending order... | 19,963 |
[
{
"content": "Explain different types of sorting algorithms in brief.",
"role": "user"
},
{
"content": "There are several types of sorting algorithms which can be used to sort a list of items. The most common ones are Bubble Sort, Insertion Sort, Selection Sort, Quick Sort, Merge Sort and Heap Sort.... | 19,964 |
[
{
"content": "Create a code to validate an email address using Regular Expressions.",
"role": "user"
},
{
"content": "```\nimport re\n\n#Function to validate an email\ndef is_valid_email(email):\n regex = '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$'\n if (re.search(regex, email)): ... | 19,965 |
[
{
"content": "Create a MySQL query to delete all the entries with the name \"John\" in the table \"users\".",
"role": "user"
},
{
"content": "DELETE FROM users WHERE name=\"John\";",
"role": "assistant"
}
] | 19,966 |
[
{
"content": "Create a pseudocode to solve the FizzBuzz problem.",
"role": "user"
},
{
"content": "```\n#For numbers from 1 through 100\nfor i from 1 to 100:\n #If the number is divisible by both 3 and 5\n if i is divisible by 3 and 5:\n #Print FizzBuzz\n print \"FizzBuzz\"\n ... | 19,967 |
[
{
"content": "Name the coding language used for developing native apps for Android.",
"role": "user"
},
{
"content": "Java",
"role": "assistant"
}
] | 19,968 |
[
{
"content": "Represent the function y = 3x + 4 in JavaScript.",
"role": "user"
},
{
"content": "y = 3*x + 4;",
"role": "assistant"
}
] | 19,969 |
[
{
"content": "Solve this regular expression problem.\nA string should start with a letter, contain only letters and numbers, and should be at least 8 characters in length.",
"role": "user"
},
{
"content": "/^[A-Za-z][A-Za-z0-9]{7,}$/",
"role": "assistant"
}
] | 19,970 |
[
{
"content": "Edit this HTML code to add a link element in the head of the page.\n<html>\n <head>\n <title>Example page</title>\n </head>\n <body>\n </body>\n</html>",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>Example page</title>\n <link href=\"style.css\" rel=\"stylesh... | 19,971 |
[
{
"content": "Create an HTML form with two dropdowns to select from different countries and cities.",
"role": "user"
},
{
"content": "<form action=\"\">\n <label>Country:</label>\n <select id=\"country\">\n <option value=\"\">-- Select Country --</option>\n <option value=\"us\">USA</option>\... | 19,972 |
[
{
"content": "Create a new class in Python that extends the existing class named 'Base'.",
"role": "user"
},
{
"content": "Class NewClass (Base):\n def __init__(self):\n super().__init__()",
"role": "assistant"
}
] | 19,973 |
[
{
"content": "In Java, construct a data structure for storing employee information, including name, age, phone number, and address.",
"role": "user"
},
{
"content": "public class Employee {\n String name;\n int age;\n String phoneNumber;\n String address;\n \n public Employee(String name... | 19,974 |
[
{
"content": "Write an algorithm in Java to reverse the words in a string.\nThe quick brown fox",
"role": "user"
},
{
"content": "String[] words = input.split(\"\\\\s\");\nString reversedString = \"\";\n \nfor (int i = words.length - 1; i >= 0; i--) \n{\n reversedString += words[i] + \" \";\n}\n\n... | 19,975 |
[
{
"content": "Create an Angular project and include the necessary dependencies for routing.",
"role": "user"
},
{
"content": "ng new angular-project\ncd angular-project\nnpm install --save @angular/router",
"role": "assistant"
}
] | 19,976 |
[
{
"content": "Write an algorithm in C that prints a string in reverse.\nHello",
"role": "user"
},
{
"content": "char str[] = \"Hello\";\nint len = strlen(str);\n\nfor (int i = len-1; i >= 0; i--) {\n printf(\"%c\", str[i]);\n}",
"role": "assistant"
}
] | 19,977 |
[
{
"content": "Write a SQL query to update the price of a product with ID 1023 to 5.",
"role": "user"
},
{
"content": "UPDATE product \n SET price = 5 \n WHERE id = 1023;",
"role": "assistant"
}
] | 19,978 |
[
{
"content": "In JavaScript, construct a function that takes two string arguments and returns the concatenation of the two strings.",
"role": "user"
},
{
"content": "function concatStrings(str1, str2) {\n return str1 + str2;\n}",
"role": "assistant"
}
] | 19,979 |
[
{
"content": "Create a CSS stylesheet and include styles for basic elements such as headings, paragraphs, and links.",
"role": "user"
},
{
"content": "h1 { \n font-size: 2em; \n color: #444; \n} \np { \n font-size: 1em; \n color: #666; \n} \n\na { \n color: #069; \n text-decoration: none; \n}"... | 19,980 |
[
{
"content": "Create a Java web application that displays a welcome message.",
"role": "user"
},
{
"content": "import java.io.IOException;\nimport java.io.PrintWriter;\n\nimport javax.servlet.ServletException;\nimport javax.servlet.annotation.WebServlet;\nimport javax.servlet.http.HttpServlet;\nimpo... | 19,981 |
[
{
"content": "Parse and extract the dates from a given text.\nThe conference will be held on Wednesday, June 16th, 2021",
"role": "user"
},
{
"content": "import re\n\ntext = \"The conference will be held on Wednesday, June 16th, 2021\"\n\n# Extract dates\ndates = re.findall(r'\\d{1,2}[-/.]\\d{1,2}[-... | 19,982 |
[
{
"content": "Write a code to find elements in an array that is divisible by a given number.\narr = [5, 15, 20, 25, 30]",
"role": "user"
},
{
"content": "# Function to find elements in an array that is \n# divisible by a given number \ndef isDivisible(arr, num): \n \n # Stores result \n res =... | 19,983 |
[
{
"content": "Create a React component to sort an array of strings.\narr = [\"test\", \"data\", \"string\"]",
"role": "user"
},
{
"content": "import React from 'react';\n\nclass SortComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n strings: thi... | 19,984 |
[
{
"content": "Write a code snippet to find the most frequent number greater than 100 from a list of numbers.\n[102, 130, 102, 140, 150, 60, 70, 102, 140]",
"role": "user"
},
{
"content": "def most_frequent(nums):\n # Initialize a dictionary to count the frequency \n # of each number in the lis... | 19,985 |
[
{
"content": "Write a JavaScript function to compute the true false ratio of a given array.\n[0, 1, 1, 0, 0]",
"role": "user"
},
{
"content": "function trueFalseRatio(arr){\n let trueCount = 0;\n let falseCount = 0;\n \n arr.forEach(val => {\n if(val === 0){\n falseCoun... | 19,986 |
[
{
"content": "Create a code to update the values of an array elements with their cube.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "def cubeArrayElements(arr): \n \n for i in range(0, len(arr)): \n arr[i] = arr[i]*arr[i]*arr[i] \n \n return arr",
"role": "assistant"
}
] | 19,987 |
[
{
"content": "Write a MongoDB query to select all documents in a collection where the field 'category' is 'clothes'.",
"role": "user"
},
{
"content": "db.collection.find({ \"category\": \"clothes\" })",
"role": "assistant"
}
] | 19,988 |
[
{
"content": "Calculate the hypotenuse of a right triangle when the other two sides are 4 and 5.",
"role": "user"
},
{
"content": "The hypotenuse of a right triangle with sides 4 and 5 is 6.40312.",
"role": "assistant"
}
] | 19,989 |
[
{
"content": "Edit the code given below so it can compute the sum of two numeric inputs.\ndef add_two_numbers(x, y):\n\t# TODO: Write code that computes and returns the sum of two numeric inputs",
"role": "user"
},
{
"content": "def add_two_numbers(x, y):\n # Compute and return the sum of two numer... | 19,990 |
[
{
"content": "Using the given datasets and Scikit-Learn, develop a K Nearest Neighbors (KNN) classifier.\nimport pandas as pd\ndf = pd.read_csv(\"data.csv\")",
"role": "user"
},
{
"content": "from sklearn.neighbors import KNeighborsClassifier \nX = df.iloc[:,:-1].values \ny = df.iloc[:,-1].values \n... | 19,991 |
[
{
"content": "Group the objects of an array into bunches of 3 using JavaScript.\n[1, 4, 7, 9, 12, 16, 19]",
"role": "user"
},
{
"content": "const groupOfThree = (arr) => {\n const chunks = [];\n let i;\n for (i = 0; i < arr.length; i+=3) {\n chunks.push(arr.slice(i, i+3));\n }\n ... | 19,992 |
[
{
"content": "Write a function in C++ to convert a list to a tuple.",
"role": "user"
},
{
"content": "#include <tuple>\n#include <vector>\n\ntemplate<typename Items>\nauto list_to_tuple(const Items& items) {\n std::tuple<Items> result;\n std::copy(items.begin(), items.end(), std::tuple_cat(res... | 19,993 |
[
{
"content": "Using the given JSON string, parse the string and convert it into an object or array in JavaScript\n{ \"name\": \"John\", \"age\": 30, \"city\": \"New York\" }",
"role": "user"
},
{
"content": "const parsedObject = JSON.parse('{ \"name\": \"John\", \"age\": 30, \"city\": \"New York\" }... | 19,994 |
[
{
"content": "Create a Node.js express server to serve a web page when the root route is requested.",
"role": "user"
},
{
"content": "const express = require('express');\nconst app = express();\n\napp.get('/', (req, res) => {\n res.send('<p>This is the homepage</p>');\n});\n\napp.listen(3000, () ... | 19,995 |
[
{
"content": "Generate a list of 10 numbers in Python where each number is a multiple of 7 and greater than 40",
"role": "user"
},
{
"content": "[x for x in range(41, 100) if x % 7 == 0]\n# Output: [42, 49, 56, 63, 70, 77, 84, 91, 98]",
"role": "assistant"
}
] | 19,996 |
[
{
"content": "Classify the given text as \"positive\" or \"negative\" using Natural Language Processing.\nThis movie is terrible.",
"role": "user"
},
{
"content": "negative",
"role": "assistant"
}
] | 19,997 |
[
{
"content": "Reorganize the given list of strings into a dictionary in JavaScript.\n[ \"name\": \"John\", \"age\": 30, \"city\": \"New York\" ]",
"role": "user"
},
{
"content": "const strList = [ \"name\": \"John\", \"age\": 30, \"city\": \"New York\" ];\nconst strDict = {};\n\nfor (i = 0; i < strL... | 19,998 |
[
{
"content": "Write a method in Java to return a reversed version of a given string.",
"role": "user"
},
{
"content": "public static String reverseString(String s) {\n StringBuilder sb = new StringBuilder();\n for (int i = s.length() - 1; i >= 0; i--) {\n sb.append(s.charAt(i));\n }\n return ... | 19,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.