messages listlengths 2 2 | conversation_id int64 0 20k |
|---|---|
[
{
"content": "Describe the purpose of an API.",
"role": "user"
},
{
"content": "An API (Application Programming Interface) is a set of programming instructions and standards used for interacting with a software application or web service. It generally enables a developer to access specific features ... | 19,500 |
[
{
"content": "Write a lambda expression to select all the strings from a given array whose length is less than 5.\narr = [\"Hello\", \"Bye\", \"Morning\", \"Evening\", \"Hi\", \"Bye Bye\"]",
"role": "user"
},
{
"content": "filtered = list(filter(lambda x : len(x) < 5, arr))",
"role": "assistant"... | 19,501 |
[
{
"content": "Identify the type of operator in the expression.\nExpression: 7 > 5",
"role": "user"
},
{
"content": "Relational Operator.",
"role": "assistant"
}
] | 19,502 |
[
{
"content": "Write a function to compare two strings and return the number of character positions at which the strings in the two strings differ from each other.\nstr1 = \"apple\"\nstr2 = \"animal\"",
"role": "user"
},
{
"content": "def compare_strings(s1, s2):\n count = 0\n for i in range(mi... | 19,503 |
[
{
"content": "Write a SQL query that updates the name of a specified employee in the 'employees' table.\nemployee_id: 101, employee_name: John",
"role": "user"
},
{
"content": "UPDATE employees \nSET employee_name='John'\nWHERE employee_id=101;",
"role": "assistant"
}
] | 19,504 |
[
{
"content": "Write a Python program for calculating the sum of a given array of numbers.\n[2, 3, 4, 5]",
"role": "user"
},
{
"content": "def calculateSum(arr): \n sum = 0\n for num in arr: \n sum += num \n return sum \n\nprint(calculateSum([2, 3, 4, 5]))",
"role": "assistant"
}
] | 19,505 |
[
{
"content": "Create an object-oriented programming class in Java named \"Car\" with three private instance variables \"make\", \"speed\" and \"color\".",
"role": "user"
},
{
"content": "public class Car { \n private String make; \n private int speed; \n private String color; \n \n publi... | 19,506 |
[
{
"content": "Write a basic SQL query to retrieve all students from the table \"Students\" and order them by their \"grade\".",
"role": "user"
},
{
"content": "SELECT * FROM Students ORDER BY grade;",
"role": "assistant"
}
] | 19,507 |
[
{
"content": "How do you perform error handling in JavaScript?",
"role": "user"
},
{
"content": "In JavaScript, error handling can be done with try...catch statements. The syntax of the try...catch statement consists of a try block followed by one or more catch clauses. The try block contains the co... | 19,508 |
[
{
"content": "Compare two strings in C# and return a Boolean indicating whether they are anagrams.\nstring1 = \"listen\";\nstring2 = \"silent\"",
"role": "user"
},
{
"content": "public static bool AreAnagrams(string string1, string string2)\n{\n if (String.Concat(string1.OrderBy(c => c)) == \n ... | 19,509 |
[
{
"content": "Given two strings, find and replace the first instance of the string1 with string2.\nstring1 = \"apple\";\nstring2 = \"apricot\";\nstring3 = \"One apple a day keeps the doctor away\"",
"role": "user"
},
{
"content": "string output = string3.Replace(string1, string2);\n// Output: One ap... | 19,510 |
[
{
"content": "Write an SQL query to select all records from a table named \"Employees\" and order the records by their salary in descending order.",
"role": "user"
},
{
"content": "SELECT * FROM Employees ORDER BY Salary DESC;",
"role": "assistant"
}
] | 19,511 |
[
{
"content": "Edit the following JavaScript function to convert Celsius to Fahrenheit.\nfunction toFahrenheit(celsius) {\n return celsius * 9/5 + 32;\n}",
"role": "user"
},
{
"content": "function toFahrenheit(celsius) {\n return celsius * 9/5 + 32;\n}\n\nfunction toCelsius(fahrenheit) {\n return ... | 19,512 |
[
{
"content": "Define a function in Python that takes a number as an argument and returns its cube.",
"role": "user"
},
{
"content": "def cube(number):\n return number**3",
"role": "assistant"
}
] | 19,513 |
[
{
"content": "Design a CSS grid container with 3 columns of equal size.",
"role": "user"
},
{
"content": ".container {\n display: grid;\n grid-template-columns: 1fr 1fr 1fr;\n}",
"role": "assistant"
}
] | 19,514 |
[
{
"content": "Build a web service that returns a list of all the customers in a MySQL database.",
"role": "user"
},
{
"content": "# Using Python:\n\n# Imports\nimport mysql.connector\n\n# Database connection\nmydb = mysql.connector.connect(\n host=\"<hostname>\",\n user=\"<username>\",\n pa... | 19,515 |
[
{
"content": "Create an interface for a number guessing game using HTML, CSS, and JavaScript.",
"role": "user"
},
{
"content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Number... | 19,516 |
[
{
"content": "Create a program to encrypt a given text using any encryption technique.\nHello",
"role": "user"
},
{
"content": "# Using Python:\n \nplain_text = \"Hello\"\n\n# Simple substitution encryption\nalphabet = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',... | 19,517 |
[
{
"content": "Create a function in Java to take a sentence as input and return a list of all the words in the sentence.\nI am a student",
"role": "user"
},
{
"content": "# Using Java:\npublic static List<String> getWords(String sentence) {\n List<String> words = new ArrayList<>();\n String[] w... | 19,518 |
[
{
"content": "Construct an SQL query to find all records where the column ‘department’ equals ‘sales’.",
"role": "user"
},
{
"content": "SELECT * FROM table WHERE department = 'sales';",
"role": "assistant"
}
] | 19,519 |
[
{
"content": "Parse a given XML string and print all the attributes present in the 'employee' tag.\n<employee name=\"John\" id=\"123\" position=\"Manager\" dept=\"Sales\" />",
"role": "user"
},
{
"content": "# Using Python: \n\nimport xml.etree.ElementTree as ET\n\nxml_string = \"<employee name=\"Jo... | 19,520 |
[
{
"content": "Generate a random boolean value using JavaScript.",
"role": "user"
},
{
"content": "# Using JavaScript:\nlet boolean = Math.random() >= 0.5;\nconsole.log(boolean);",
"role": "assistant"
}
] | 19,521 |
[
{
"content": "Write a shell script to print all the environment variables in use.",
"role": "user"
},
{
"content": "# Using Bash:\n\n# Print the environment variables\nfor var in $(env); do\n echo \"$var\";\ndone",
"role": "assistant"
}
] | 19,522 |
[
{
"content": "Populate an array with numbers from 1 to 10 in Python.",
"role": "user"
},
{
"content": "arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"role": "assistant"
}
] | 19,523 |
[
{
"content": "Design a loop in Ruby that prints \"Hello World\" 10 times.",
"role": "user"
},
{
"content": "10.times do \n puts “Hello World”\n end",
"role": "assistant"
}
] | 19,524 |
[
{
"content": "Construct a recursive function in JavaScript that calculates the total sum of an array.\narr = [1, 2, 3, 4, 5, 6]",
"role": "user"
},
{
"content": "function sumArray(arr) { \n if (arr.length === 0) { \n return 0; \n } \n return arr[0] + sumArray(arr.slice(1)); \n} \nlet r... | 19,525 |
[
{
"content": "Write a PHP program that prints the contents of a multidimensional array.\narr = [[1,2], [3,4]]",
"role": "user"
},
{
"content": "<?php\n $arr = [[1,2], [3,4]];\n \n function printArray($arr) {\n foreach($arr as $row) {\n foreach($row as $element){\n ... | 19,526 |
[
{
"content": "Create a program in Java that takes an array with two integers as input and prints the multiplication of those two input integers.\narr = [3, 4]",
"role": "user"
},
{
"content": "public class Main {\n public static void main(String[] args) {\n int[] arr = {3,4};\n \n int num1... | 19,527 |
[
{
"content": "Determine the frequency of each word in a sentence using a hashmap in JavaScript.\ns = \"This is a test sentence\"",
"role": "user"
},
{
"content": "let string = \"This is a test sentence\";\nlet wordsArray = string.split(\" \"); \nlet frequencyMap = {};\nwordsArray.forEach(word => {\n... | 19,528 |
[
{
"content": "Construct a bubblesort algorithm in Python.",
"role": "user"
},
{
"content": "def bubbleSort(array): \n\tn = len(array) \n\tfor i in range (n): \n\t\tfor j in range(0, n-i-1): \n\t\t\tif array[j] > array[j+1] : \n\t\t\t\tarray[j], array[j+1] = array[j+1], array[j] \n\narr = [64, 34, 25... | 19,529 |
[
{
"content": "Design a function in JavaScript to print all natural numbers between 1 to n.",
"role": "user"
},
{
"content": "function printNumbers (n) {\n for (let i = 1; i <= n; i++) {\n console.log(i);\n }\n}",
"role": "assistant"
}
] | 19,530 |
[
{
"content": "Generate a valid HTML page given the body contents.\n<h1>Hello World!</h1>\n<p>This is a simple HTML page.</p>",
"role": "user"
},
{
"content": "<html>\n <head>\n </head>\n <body>\n <h1>Hello World!</h1>\n <p>This is a simple HTML page.</p>\n </body>\n</html>"... | 19,531 |
[
{
"content": "Generate a valid XML tag to represent the following:\nName: User; Attribute: id; Attribute Value: 47",
"role": "user"
},
{
"content": "<User id=\"47\" />",
"role": "assistant"
}
] | 19,532 |
[
{
"content": "Suggest a 3D modelling software for creating 3D designs.",
"role": "user"
},
{
"content": "Blender is a free and open source 3D modelling software which can be used to create 3D designs.",
"role": "assistant"
}
] | 19,533 |
[
{
"content": "Summarize a MySQL query that prints out the names and grades of students from a table.\nStudents (name, grade)\n\nHarry, A\n\nSelman, B\n\nLinda, A",
"role": "user"
},
{
"content": "SELECT name, grade FROM Students; \n\nThis query will return the names and grades of all students from t... | 19,534 |
[
{
"content": "How would you modify the query to print the average grade of the students?\nSELECT name, grade FROM Students;",
"role": "user"
},
{
"content": "SELECT AVG(grade) FROM Students; \n\nThis query will return the average grade of all students from the Students table.",
"role": "assistan... | 19,535 |
[
{
"content": "Create a JavaScript function to get the last item of an array.",
"role": "user"
},
{
"content": "function getLastItem(arr) {\n return arr[arr.length - 1];\n}",
"role": "assistant"
}
] | 19,536 |
[
{
"content": "Write a query in PostgreSQL to find the total number of students with an A grade.",
"role": "user"
},
{
"content": "SELECT COUNT(*) FROM Students WHERE grade = 'A';\n\nThis query will return the total number of students with an A grade.",
"role": "assistant"
}
] | 19,537 |
[
{
"content": "Rewrite the following JavaScript snippet to use a ternary statement.\nlet x = 10;\n\nif (x > 0) {\n x = x + 5;\n} else {\n x = x - 5;\n}",
"role": "user"
},
{
"content": "let x = 10;\n\nx = x > 0 ? x + 5 : x - 5;",
"role": "assistant"
}
] | 19,538 |
[
{
"content": "Suggest a data structure in Python to represent a binary search tree.",
"role": "user"
},
{
"content": "A Binary Search Tree (BST) can be represented using the dictionary data structure in Python. Each node in the tree will be represented by a dictionary containing the keys: ‘value’, ‘... | 19,539 |
[
{
"content": "Create a REST API endpoint to retrieve specific user data from the database\nA relational database with a user table containing: user_id, email, phone_number",
"role": "user"
},
{
"content": "@app.route('/user', methods=['GET'])\ndef get_user():\n user_id = request.args.get('user_id... | 19,540 |
[
{
"content": "Create a C++ class to store data of an employee\nEmployee Data: employee_id, name, salary",
"role": "user"
},
{
"content": "class Employee{\nprivate:\n int employeeId;\n String name;\n int salary;\n\npublic:\n Employee(int employeeId, String name, int salary){\n this... | 19,541 |
[
{
"content": "Create a Node.js server to handle POST requests\nNone",
"role": "user"
},
{
"content": "const http = require('http');\nconst fs = require('fs');\nconst port = 3000;\n\nconst server = http.createServer((req, res) => { \n if (req.method == 'POST') {\n let body = '';\n re... | 19,542 |
[
{
"content": "Create a text box containing the given text\nTextbox Text: Welcome",
"role": "user"
},
{
"content": "<input type=\"text\" value=\"Welcome\" />",
"role": "assistant"
}
] | 19,543 |
[
{
"content": "Identify the type of error in the below given syntax\na < 45",
"role": "user"
},
{
"content": "Syntax Error. The correct syntax should be \"a < 45\".",
"role": "assistant"
}
] | 19,544 |
[
{
"content": "Create a MongoDB document containing the following data\nName: John\nAge: 32\nOccupation: Engineer",
"role": "user"
},
{
"content": "{\n name: \"John\",\n age: 32,\n occupation: \"Engineer\"\n}",
"role": "assistant"
}
] | 19,545 |
[
{
"content": "Create a C# method to get the current system time\nNone",
"role": "user"
},
{
"content": "public DateTime GetCurrentTime() {\n return DateTime.Now;\n}",
"role": "assistant"
}
] | 19,546 |
[
{
"content": "Create a class Employee in Java which contains the name, age and salary of the employee.",
"role": "user"
},
{
"content": "public class Employee {\n private String name;\n private int age;\n private double salary;\n \n public Employee() { }\n \n public Employee(Str... | 19,547 |
[
{
"content": "Find the top 10 customers based on total purchase amount from the \"customers\" data table.",
"role": "user"
},
{
"content": "SELECT TOP 10 c.id, c.name, SUM(d.amount) as total_purchase \nFROM customers c\nINNER JOIN details d ON c.id = d.customer_id\nGROUP BY c.id, c.name\nORDER BY to... | 19,548 |
[
{
"content": "Create a simple webpage to welcome visitors with a centered heading \"Welcome\".",
"role": "user"
},
{
"content": "<!DOCTYPE html>\n<html>\n<head>\n <title>Welcome</title>\n <style>\n h1 {\n text-align: center;\n }\n </style>\n</head>\n<body>\n<h1>Welcome</h1>\n</body>\n</html>",
... | 19,549 |
[
{
"content": "Convert a list to a string.\nmy_list = [\"a\", \"b\", \"c\", \"d\"]",
"role": "user"
},
{
"content": "my_list = [\"a\", \"b\", \"c\", \"d\"]\n\n# Convert the list to a string \nmy_string = ''.join(my_list)\n\nprint(my_string) # Output: abcd",
"role": "assistant"
}
] | 19,550 |
[
{
"content": "Create a function that takes as input a string and evaluates its quantity to true or false.",
"role": "user"
},
{
"content": "def is_empty(str):\n ''' This function takes as input a string and evaluates its \n quantity to true or false.\n '''\n if len(str.strip()) == 0:\n re... | 19,551 |
[
{
"content": "Write a regular expression to check if a string ends with \"py\".",
"role": "user"
},
{
"content": "import re\n\npattern = r\"py$\"\n\n# Check if a string ends with \"py\"\nif re.search(pattern, \"test.py\"):\n print(\"String ends with 'py'.\") # Output: String ends with 'py'.",
"... | 19,552 |
[
{
"content": "Train a machine learning model to predict whether a customer is likely to purchase a product.",
"role": "user"
},
{
"content": "import pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier\n\n# Read d... | 19,553 |
[
{
"content": "Compile and execute this program using the C++ compiler.\n#include <iostream>\n\nint main() {\n std::cout << \"Hello, World!\" << std::endl;\n return 0;\n}",
"role": "user"
},
{
"content": "The program can be compiled with the command \"g++ <filename>\".\nThe program can be executed wi... | 19,554 |
[
{
"content": "Write a function that takes an array of integers and returns an array of the same length with each element multiplied by 2.\n[1, 2, 3]",
"role": "user"
},
{
"content": "def multiplyByTwo(arr):\n multipliedArr = []\n for i in arr:\n multipliedArr.append(i*2)\n return mul... | 19,555 |
[
{
"content": "Find a way to solve this particular problem using regex.\nGiven a string \"A-C-E-G-I\", create a new string \"ACE-GI\".",
"role": "user"
},
{
"content": "The following regex expression can be used to solve this problem: \n(?<=.)(?=-.)|(?<!-.)",
"role": "assistant"
}
] | 19,556 |
[
{
"content": "Create a SQL query to find the average length of time for all purchases.\nTable structure: \nPurchase (Customer_ID, Purchase_Date, Purchase_Length)",
"role": "user"
},
{
"content": "SELECT AVG(Purchase_Length) as Average_Purchase_Length \nFROM Purchase;",
"role": "assistant"
}
] | 19,557 |
[
{
"content": "Construct a machine learning model to classify a given dataset into two class labels.\nDataset",
"role": "user"
},
{
"content": "Using a dataset with two class labels (e.g., yes/no, 0/1, etc.), a machine learning model can be constructed, for example, by using a Support Vector Machine ... | 19,558 |
[
{
"content": "Create a tensorflow model to predict the probability of rain given an input dataset.\nWeather dataset",
"role": "user"
},
{
"content": "The following steps can be taken to create a tensorflow model to predict the probability of rain given an input dataset:\n\n1. Preprocess and clean th... | 19,559 |
[
{
"content": "Convert the following list into a dictionary in Python: [1, 2, 3, 4, 5].",
"role": "user"
},
{
"content": "my_dict = {1:1, 2:2, 3:3, 4:4, 5:5}",
"role": "assistant"
}
] | 19,560 |
[
{
"content": "Create a HTML web page with a header, a body and a footer section.",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>My Web Page</title>\n </head>\n <body>\n <!-- content goes here -->\n </body>\n <footer>\n <!-- footer content goes here -->\n </footer>\n</html>... | 19,561 |
[
{
"content": "Generate code for a function that takes a string and returns its reverse.",
"role": "user"
},
{
"content": "def reverseStr(string): \n reversedString = \"\" \n for i in range(len(string) -1, -1, -1): \n reversedString += string[i] \n return reversedString",
"role": ... | 19,562 |
[
{
"content": "Write a two-column HTML table with the film names as the first column and the release year as the second column.\nHarry Potter (2001)\nAvengers (2012)\n\n<noinput>",
"role": "user"
},
{
"content": "<table>\n <tr>\n <th>Film Name</th>\n <th>Release Year</th>\n </tr>\n <tr>\n ... | 19,563 |
[
{
"content": "Design a CSS class with a width of 400px and a height of 200px and a border of 3px dotted yellow.",
"role": "user"
},
{
"content": ".myClass {\n width: 400px;\n height: 200px;\n border: 3px dotted yellow;\n}",
"role": "assistant"
}
] | 19,564 |
[
{
"content": "Generate a random string of length 5 with only lowercase alphabetic characters.",
"role": "user"
},
{
"content": "import string\nimport random\n\ndef generate_random_string(length):\n allowed_characters = string.ascii_lowercase\n return ''.join(random.choices(allowed_characters, ... | 19,565 |
[
{
"content": "Write a lambda expression to show the first character of a string.",
"role": "user"
},
{
"content": "x = lambda a : a[0]\nprint(x(\"Hello\"))",
"role": "assistant"
}
] | 19,566 |
[
{
"content": "Write a Python program to find the sum of Fibonacci numbers till the number 7.",
"role": "user"
},
{
"content": "def fibonacci(n): \n f1 = 0\n f2 = 1\n sum_fib = 0\n for i in range(2, n + 1): \n next_term = f1 + f2 \n sum_fib += next_term\n f1 = f2\n ... | 19,567 |
[
{
"content": "Implement a comparison operator that takes two strings as arguments and returns true if the strings are equal and false otherwise.",
"role": "user"
},
{
"content": "def equals(str1, str2):\n \"\"\"Compares two strings to see if they are equal.\"\"\"\n return str1 == str2",
"r... | 19,568 |
[
{
"content": "Write a Python program that uses the function \"get_name\" to ask the user for their full name and then prints it back to them.",
"role": "user"
},
{
"content": "def get_name():\n \"\"\"Gets a user's full name .\"\"\"\n first_name = input(\"What is your first name? \")\n last_... | 19,569 |
[
{
"content": "Manipulate the string \"Hello, World!\" using the correct Python function that will replace the word \"Hello\" with \"Goodbye\".",
"role": "user"
},
{
"content": "def goodbye_world(string):\n \"\"\"Replaces the word Hello with Goodbye in the string.\"\"\"\n return string.replace(... | 19,570 |
[
{
"content": "Write code to take two numbers and determine if their product is even.\n8, 12",
"role": "user"
},
{
"content": "def is_sum_even(num1, num2):\n \"\"\"Checks if the product of two numbers is even or odd.\"\"\"\n sum = num1 * num2\n return sum % 2 == 0\n\nif __name__ == \"__main_... | 19,571 |
[
{
"content": "Sort the given list according to the last three digits of every number.\n[332, 555, 898, 876]",
"role": "user"
},
{
"content": "def sort_list(numbers):\n \"\"\"Sorts a list of numbers according to the last three digits of each number.\"\"\"\n return sorted(numbers, key=lambda x: ... | 19,572 |
[
{
"content": "Take a string and remove all the duplicated words within it.",
"role": "user"
},
{
"content": "def remove_duplicates(string):\n \"\"\"Removes all repeated words from a string.\"\"\"\n words = string.split()\n seen = set()\n result = []\n for word in words:\n if wo... | 19,573 |
[
{
"content": "Write a function that returns the day of the week given a date.\ndate = '2020-12-30'",
"role": "user"
},
{
"content": "date = '2020-12-30'\n\nimport datetime\n\ndef getDayofWeek(date):\n # Convert the string to datetime\n d = datetime.datetime.strptime(date, \"%Y-%m-%d\")\n # ... | 19,574 |
[
{
"content": "Given three numbers, write a code to find the maximum among them.\nx = 10\ny = 15\nz = 5",
"role": "user"
},
{
"content": "x = 10\ny = 15\nz = 5\n\n# Find the maximum\nmax_val = max(x, y, z)\n\nprint(f\"The maximum among {x}, {y}, and {z} is {max_val}.\")",
"role": "assistant"
}
... | 19,575 |
[
{
"content": "Given a sequence of strings, write a code to check if all the strings in the sequence are unique.\narr = [\"cat\",\"dog\",\"mouse\"]",
"role": "user"
},
{
"content": "arr = [\"cat\",\"dog\",\"mouse\"]\n\n# Check if the strings are unique\ndef is_unique(arr):\n seen = set()\n for ... | 19,576 |
[
{
"content": "Write a Python program to create a Caesar Cipher encryption algorithm.",
"role": "user"
},
{
"content": "def cipher(input_str, key):\n output_str = \"\"\n\n for char in input_str:\n if char.isalpha():\n # Encrypt each character\n ascii_value = ord(char)\n ascii_valu... | 19,577 |
[
{
"content": "Write a SQL query to select only unique rows.",
"role": "user"
},
{
"content": "SELECT DISTINCT *\nFROM table",
"role": "assistant"
}
] | 19,578 |
[
{
"content": "Create a HQL query to sort records by descending order.",
"role": "user"
},
{
"content": "SELECT *\nFROM table\nORDER BY column DESC",
"role": "assistant"
}
] | 19,579 |
[
{
"content": "Given a collection of integers, write a code to sort the integers in ascending order.\narr = [5, 7, 3, 8, 10]",
"role": "user"
},
{
"content": "arr = [5, 7, 3, 8, 10]\n\n# Sort the array\narr.sort()\n\nprint(f\"Sorted list: {arr}\")",
"role": "assistant"
}
] | 19,580 |
[
{
"content": "Write an R statement to calculate the probability of getting a number greater than 5 from a range of 1 to 10.",
"role": "user"
},
{
"content": "# Calculate the probability\nprobability = mean(x > 5)\n\nprint(f\"Probability of getting a number greater than 5 from a range of 1 to 10 is {... | 19,581 |
[
{
"content": "Write a code to convert a list of comma or semicolon separated strings into a single string.\nlist = ['apple', 'orange', 'banana']",
"role": "user"
},
{
"content": "def convert_list_to_str(list):\n return \";\".join(list) \n\nprint(convert_list_to_str(list))",
"role": "assistant... | 19,582 |
[
{
"content": "Write a code to filter out numbers which are divisible by 3 and 5 from a given list.\nlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"role": "user"
},
{
"content": "def filter_3_5(nums): \n return [num for num in nums if num % 3 == 0 and num % 5 == 0]\n\nprint(filter_3_5(list))",
"rol... | 19,583 |
[
{
"content": "What is the Python equivalent of the C++ code snippet?\n#include <iostream>\n\nint main() {\n std::cout << \"Hello, World!\" << std::endl;\n return 0;\n}",
"role": "user"
},
{
"content": "print(\"Hello, World!\")",
"role": "assistant"
}
] | 19,584 |
[
{
"content": "Generate an HTML element which displays the phrase \"Hello, World!\"",
"role": "user"
},
{
"content": "<p>Hello, World!</p>",
"role": "assistant"
}
] | 19,585 |
[
{
"content": "Create a class named 'Car' with the given properties.\nclass Car: Make, Model, Year",
"role": "user"
},
{
"content": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year",
"role": "assistant"
}
] | 19,586 |
[
{
"content": "Create a JavaScript function named 'calculateAge' that determines a person's age based on the birth year given.",
"role": "user"
},
{
"content": "function calculateAge(birthYear) {\n let age = 2019 - birthYear;\n return age;\n}",
"role": "assistant"
}
] | 19,587 |
[
{
"content": "Create a method named 'combine' to combine two strings.\nString str1 = \"Hello\";\nString str2 = \"World\";",
"role": "user"
},
{
"content": "public String combine(String str1, String str2) {\n return str1+str2;\n}",
"role": "assistant"
}
] | 19,588 |
[
{
"content": "Create a function in JavaScript that takes in a number and a power, and returns the result of the power operation on the number.\nnum = 2, pow = 5",
"role": "user"
},
{
"content": "function power(num, pow) {\n let result = 1;\n for (let i = 1; i <= pow; i++) {\n result *= ... | 19,589 |
[
{
"content": "Using PHP, write a code to print out the current date and time in the following format: Thursday, December 18 at 4:30 PM",
"role": "user"
},
{
"content": "echo date('l, F j \\a\\\\t g:i A');",
"role": "assistant"
}
] | 19,590 |
[
{
"content": "Using jQuery, write a script to select all elements with the classname \"highlight\".",
"role": "user"
},
{
"content": "$('.highlight').each(function () { \n $(this).addClass('selected'); \n});",
"role": "assistant"
}
] | 19,591 |
[
{
"content": "Create an HTML form that takes the user's name, email, and photo and saves it in a database.",
"role": "user"
},
{
"content": "<form method=\"post\" action=\"submit.php\">\n <input type=\"text\" name=\"name\" placeholder=\"Name\" required>\n <input type=\"email\" name=\"email\" place... | 19,592 |
[
{
"content": "Write a SQL query to find the top 3 most visited websites on a specific day.",
"role": "user"
},
{
"content": "SELECT name, COUNT(*) as visits \nFROM websites\nWHERE date = 'DD-MM-YYYY'\nGROUP BY name\nORDER BY visits DESC\nLIMIT 3;",
"role": "assistant"
}
] | 19,593 |
[
{
"content": "Implement a tournament bracket for a single elimination tournament using C programming.",
"role": "user"
},
{
"content": "#include <stdio.h>\n#include <stdlib.h>\n\n#define MAX_NUM_TEAMS 8\n\nstruct team { \n int teamID; \n char name[30]; \n};\n\nstruct bracket {\n struct team *team... | 19,594 |
[
{
"content": "Output a Regex expression to match all dates in the following format dd/mm/yyyy",
"role": "user"
},
{
"content": "^(0[1-9]|[12][0-9]|3[01])\\/(0[1-9]|1[0-2])\\/[0-9]{4}$",
"role": "assistant"
}
] | 19,595 |
[
{
"content": "Convert the following hexadecimal number FA to its binary form.\nFA",
"role": "user"
},
{
"content": "11111010",
"role": "assistant"
}
] | 19,596 |
[
{
"content": "Calculate the area of a triangle with base b=4 and height h = 5.",
"role": "user"
},
{
"content": "The area of the triangle is 10 square units.",
"role": "assistant"
}
] | 19,597 |
[
{
"content": "Write a SQL query to update the status of all rows in the ‘customers’ table from active to inactive.",
"role": "user"
},
{
"content": "UPDATE customers SET status = 'inactive' WHERE status = 'active';",
"role": "assistant"
}
] | 19,598 |
[
{
"content": "Write a Mongoose query to remove a document with a date field that has a value of 2021-01-05.",
"role": "user"
},
{
"content": "Model.remove({date: '2021-01-05'});",
"role": "assistant"
}
] | 19,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.