messages listlengths 2 2 | conversation_id int64 0 20k |
|---|---|
[
{
"content": "Calculate 3 to the 5th power.",
"role": "user"
},
{
"content": "243",
"role": "assistant"
}
] | 19,600 |
[
{
"content": "Optimize the following C code with a faster algorithm.\n// C Program to find the minimum element in an array\n#include <stdio.h>\nint main()\n{\n int array[100], minimum, size, c, location = 1;\n \n printf(\"Enter the number of elements in array\\n\");\n scanf(\"%d\",&size);\n \n printf(\"... | 19,601 |
[
{
"content": "Parse a given XML element.\n<root><book>Python for Dummies</book></root>",
"role": "user"
},
{
"content": "def parse_xml(element):\n root = element.find('root')\n book = root.find('book').text\n return book",
"role": "assistant"
}
] | 19,602 |
[
{
"content": "Generate an array with the following pattern [2, 4, 8, 16, ....1024]",
"role": "user"
},
{
"content": "def generate_pattern(x):\n arr = []\n for i in range(11):\n arr.append(x**i)\n return arr",
"role": "assistant"
}
] | 19,603 |
[
{
"content": "explain the concept of static variables in a programming language",
"role": "user"
},
{
"content": "Static variables are variables which retain their value over multiple function calls. They are declared with the \"static\" keyword and can be accessed within the same scope in which the... | 19,604 |
[
{
"content": "Classify text whether it is opinionated or objective.\nToday's climate is the warmest it has ever been.",
"role": "user"
},
{
"content": "Opinionated",
"role": "assistant"
}
] | 19,605 |
[
{
"content": "Fix the code so that it increments the number by 10 each time.\nnum = 0\nwhile num <= 10:\n num += 1",
"role": "user"
},
{
"content": "num = 0\nwhile num <= 10:\n num += 10",
"role": "assistant"
}
] | 19,606 |
[
{
"content": "Write a function that receives an array and removes every odd element from it.\n[1, 2, 3, 4, 5, 6, 7, 8]",
"role": "user"
},
{
"content": "def remove_odd(arr):\n return [i for i in arr if i % 2 == 0]",
"role": "assistant"
}
] | 19,607 |
[
{
"content": "Write a JavaScript program for converting a two-dimensional array into a one-dimensional array.\n[\n [1,2],\n [3,4],\n [5,6]\n]",
"role": "user"
},
{
"content": "function twoDToOneD(arr) {\n let res = [];\n for (let i = 0; i < arr.length; i++) {\n for (let j = 0; ... | 19,608 |
[
{
"content": "Create a Ruby class for a customer and add attributes for name, age and address.",
"role": "user"
},
{
"content": "class Customer\n attr_accessor :name, :age, :address\n\n def initialize(name, age, address)\n @name = name\n @age = age\n @address = address\n end\nend",
"... | 19,609 |
[
{
"content": "What are the features of the Cython coding language?",
"role": "user"
},
{
"content": "Cython is a programming language that combines the speed and flexibility of Python with the static typing system of C and C++. Features of Cython include type inference, function overloading, optiona... | 19,610 |
[
{
"content": "Write a code for creating multiple variables with a single statement in Python.",
"role": "user"
},
{
"content": "x, y, z = 1, 2, 3",
"role": "assistant"
}
] | 19,611 |
[
{
"content": "Write a script for swapping two variables in Ruby.",
"role": "user"
},
{
"content": "x, y = y, x",
"role": "assistant"
}
] | 19,612 |
[
{
"content": "What is the difference between deep learning and traditional AI?",
"role": "user"
},
{
"content": "The primary difference between deep learning and traditional AI is the way they process and interpret data. Deep learning uses a multi-layered artificial neural network in order to learn ... | 19,613 |
[
{
"content": "Create a series of nested for loops in Java to print the numbers from 1 to 10 in descending order on a single line.",
"role": "user"
},
{
"content": "for (int i = 10; i >= 1; i--) \n System.out.print(i + \" \");",
"role": "assistant"
}
] | 19,614 |
[
{
"content": "Use the reduce method in JavaScript to add a given array of numbers together.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "let sum = [1, 2, 3, 4, 5].reduce((acc, currentVal) => acc + currentVal, 0);",
"role": "assistant"
}
] | 19,615 |
[
{
"content": "Create an if-else statement in C++ to check if an integer number is greater than 0.",
"role": "user"
},
{
"content": "if (number > 0) \n cout << number << \" is greater than 0\" << endl;\nelse\n cout << number << \" is not greater than 0\" << endl;",
"role": "assistant"
}
] | 19,616 |
[
{
"content": "Write an algorithm in Java to reverse an array.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "int[] reverse = new int[arr.length]; \n \nint j = arr.length; \n \n// Initializing the index of reverse array \nint i; \n \nfor (i = 0; i < arr.length; i++) \n{ \n reverse[j - 1] = ... | 19,617 |
[
{
"content": "Create a switch statement in Swift to display \"The number is greater than 10\" when the given number is greater than 10.",
"role": "user"
},
{
"content": "switch number {\n case _ where number > 10: \n print(\"The number is greater than 10\") \n default: \n break \n}",
"role... | 19,618 |
[
{
"content": "Design a function in JavaScript to take in two strings as parameters and return true if the strings are anagrams and false otherwise.",
"role": "user"
},
{
"content": "function isAnagram(string1, string2) { \n \n // Convert both strings to lowercase \n var s1 = string1.toLowerCa... | 19,619 |
[
{
"content": "Develop a query in SQL to display all columns from a table named 'products' with a product price greater than 10.",
"role": "user"
},
{
"content": "SELECT * FROM products WHERE price > 10;",
"role": "assistant"
}
] | 19,620 |
[
{
"content": "Write an expression using operator overloading in C++ to simulate addition of two objects.",
"role": "user"
},
{
"content": "// Operator Overloading in C++ \nclass MyClass \n{ \n public: \n int x; \n \n // Overload + operator to add two objects. \n MyClass oper... | 19,621 |
[
{
"content": "Compose a for loop in Java to print the numbers from 4 to 1 one line.",
"role": "user"
},
{
"content": "for (int i = 4; i > 0; i--) {\n System.out.print(i + \" \");\n}",
"role": "assistant"
}
] | 19,622 |
[
{
"content": "Write code in Python to extract all the words from a sentence and store them in an array.\n\"Hello World!\"",
"role": "user"
},
{
"content": "words = sentence.split(\" \")",
"role": "assistant"
}
] | 19,623 |
[
{
"content": "Create an algorithm to traverse a binary tree in pre-order in Python.",
"role": "user"
},
{
"content": "# A function to do preorder tree traversal\ndef preOrder(root):\n \n # Base Case\n if root is None:\n return\n \n # First print the data of node\n print(root.data... | 19,624 |
[
{
"content": "Create a script in Bash to navigate to a given directory and list all its contents.",
"role": "user"
},
{
"content": "#!/bin/bash\n\n# Navigates to the given directory\ncd $1\n\n# Print all contents of the directory\nls",
"role": "assistant"
}
] | 19,625 |
[
{
"content": "Use the reduce method in JavaScript to find the maximum value in a given array.\n[1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "let maxNum = [1, 2, 3, 4, 5].reduce(function(a, b){\n return Math.max(a, b)\n});",
"role": "assistant"
}
] | 19,626 |
[
{
"content": "Create a web page that contains three input boxes for a user to input name, age, and gender.",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>Input Form</title>\n </head>\n <body>\n <form>\n Name:<br>\n <input type=\"text\" name=\"... | 19,627 |
[
{
"content": "Generate a valid SQL query that finds out the number of rows stored in a table",
"role": "user"
},
{
"content": "SELECT COUNT(*) FROM table_name;",
"role": "assistant"
}
] | 19,628 |
[
{
"content": "Create a basic HTML skeleton for a web page.",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>Basic Webpage</title>\n </head>\n <body>\n\n </body>\n</html>",
"role": "assistant"
}
] | 19,629 |
[
{
"content": "Write a for loop in JavaScript that iterates 10 times and prints a message each time.",
"role": "user"
},
{
"content": "for (let i = 0; i < 10; i++) {\n console.log(`Iteration number ${i}`);\n}",
"role": "assistant"
}
] | 19,630 |
[
{
"content": "Create a basic form in HTML containing two input boxes for first name and surname.",
"role": "user"
},
{
"content": "<html>\n <head>\n <title>User Information Form</title>\n </head>\n <body>\n <form>\n First Name:<br>\n <input type=\"text\" name=\"firstname\"><br>\n ... | 19,631 |
[
{
"content": "Write a Java program that prompts the user to enter two strings and outputs whether the two strings are anagrams.",
"role": "user"
},
{
"content": "import java.util.HashMap;\n\npublic class Anagram { \n\n // Utility method to check whether two strings are anagram or not \n static... | 19,632 |
[
{
"content": "Given two strings, sort them in alphabetically ascending order.\n\"javascript\"\n\"python\"",
"role": "user"
},
{
"content": "def sort_str(str1, str2): \n # extract the words from the strings \n str1_list = list (map (str, str1)) \n str2_list = list (map (str, str2)) \n \n ... | 19,633 |
[
{
"content": "Write a Python program to determine if an input string is a valid IP address.",
"role": "user"
},
{
"content": "import re\ndef isValidIP(ip): \n # check if the string is a valid IP address\n regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \n 25[0-5]|2[0-4][0-9]... | 19,634 |
[
{
"content": "Write an SQL query that returns the average age for students in a specific class.",
"role": "user"
},
{
"content": "SELECT AVG(age)\nFROM students\nWHERE class = 'XYZ';",
"role": "assistant"
}
] | 19,635 |
[
{
"content": "Write a function to print the spiral ordering of an input matrix.\n[[1, 2, 3], \n [4, 5, 6], \n [7, 8, 9]]",
"role": "user"
},
{
"content": "def spiralPrint(m, n, a) : \n k = 0; l = 0\n \n ''' k - starting row index \n m - ending row index \n l - starting column in... | 19,636 |
[
{
"content": "Create a SQL query to sort a table by its numerical contents.\nTable: \n\n+-----------+-----------+\n| Name | Score |\n+-----------+-----------+\n| John | 90 |\n| Mary | 80 |\n| Miguel | 75 |\n| Fanny | 99 |\n+-----------+-----------+",
"ro... | 19,637 |
[
{
"content": "Write a regular expression to match the phrase \"hello people\"",
"role": "user"
},
{
"content": "/hello\\s+people/",
"role": "assistant"
}
] | 19,638 |
[
{
"content": "Create a CSS class that aligns its content left.",
"role": "user"
},
{
"content": ".left-align {\n text-align: left;\n}",
"role": "assistant"
}
] | 19,639 |
[
{
"content": "Construct an HTML form element to define a required input field.",
"role": "user"
},
{
"content": "<input type=\"text\" required>",
"role": "assistant"
}
] | 19,640 |
[
{
"content": "Create a JavaScript loop with the condition i < 5.",
"role": "user"
},
{
"content": "for (let i = 0; i < 5; i++) {\n ...\n}",
"role": "assistant"
}
] | 19,641 |
[
{
"content": "Write a function in Python to return the first n digits of the Fibonacci sequence.\nn = 5",
"role": "user"
},
{
"content": "def fibonacci(n): \n a = 0\n b = 1\n if n < 0: \n print(\"Incorrect input\") \n elif n == 0: \n return a \n elif n == 1: \n re... | 19,642 |
[
{
"content": "Create an array in C++ of 10 integers and assign them all to 0.",
"role": "user"
},
{
"content": "int numbers[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};",
"role": "assistant"
}
] | 19,643 |
[
{
"content": "Construct a query in SQL to group records by some value.\nTable: \n\n+-----------+-----------+\n| Item | Category |\n+-----------+-----------+\n| Pencil | Office |\n| Phone | Electronics|\n| Pen | Office |\n| Monitor | Electronics|\n+-----------+-----------+",
"role"... | 19,644 |
[
{
"content": "Create a C# class that contains a constructor.",
"role": "user"
},
{
"content": "public class Example{\n public int num;\n \n public Example(int num){\n this.num = num;\n }\n}",
"role": "assistant"
}
] | 19,645 |
[
{
"content": "Create a Python loop that iterates for 10 times.",
"role": "user"
},
{
"content": "for i in range(10):\n ...",
"role": "assistant"
}
] | 19,646 |
[
{
"content": "Create a regex to extract links from a block of text\nText: The website www.example.com has great resources",
"role": "user"
},
{
"content": "Regex: https?://[\\w\\d./]+",
"role": "assistant"
}
] | 19,647 |
[
{
"content": "Create a sass function to change the text color of a web page",
"role": "user"
},
{
"content": "@function text-color($text-color, $background-color) {\n // Calculate how much Black and White needs to be in the text to be readable\n $res: 0;\n $black: 0;\n $white: 0;\n\n @if (light... | 19,648 |
[
{
"content": "Write an XPATH expression to select an element with a specific id",
"role": "user"
},
{
"content": "//*[@id=\"myElement\"]",
"role": "assistant"
}
] | 19,649 |
[
{
"content": "Create a Node.js module to return the highest value in an array",
"role": "user"
},
{
"content": "const findHighestValue = arr => {\n let highest = null;\n arr.forEach(num => {\n if (!highest || num > highest) {\n highest = num;\n }\n });\n return highest;\n};\n\nmodule.... | 19,650 |
[
{
"content": "Create a postgres query to select all rows from a table named 'employee' where the age is greater than 25",
"role": "user"
},
{
"content": "SELECT * FROM employee WHERE age > 25;",
"role": "assistant"
}
] | 19,651 |
[
{
"content": "Write a python script that takes user input and prints out the squares of the numbers",
"role": "user"
},
{
"content": "# Take input from user\nnumbers = input(\"Enter numbers: \") \n \n# split the string \nnumbers = list(map(int, numbers.split(' '))) \n \n# Loop to print the squares... | 19,652 |
[
{
"content": "Extract the values of the keys of a given dictionary.\nDictionary = {'name': 'John', 'age': 35, 'job': 'teacher'}",
"role": "user"
},
{
"content": "name - John\nage - 35\njob - teacher",
"role": "assistant"
}
] | 19,653 |
[
{
"content": "Output the size of the below list.\nlist_a = [1, 2, 3, 4]",
"role": "user"
},
{
"content": "4",
"role": "assistant"
}
] | 19,654 |
[
{
"content": "Create and fill a 2-dimensional list with the dimensions n and m.\nn = 3, m = 5",
"role": "user"
},
{
"content": "list_2d = [[0 for i in range(m)] for j in range(n)]",
"role": "assistant"
}
] | 19,655 |
[
{
"content": "Parse the following string to obtain all the digits.\nstr1 = \"Price of the product is $128.\"",
"role": "user"
},
{
"content": "'128'",
"role": "assistant"
}
] | 19,656 |
[
{
"content": "Divide the list into two equal halves and output them.\nlist_c = [1,2,3,4,5,6]",
"role": "user"
},
{
"content": "list1 = [1,2,3]\nlist2 = [4,5,6]",
"role": "assistant"
}
] | 19,657 |
[
{
"content": "Annotate the given code with its function\ndef foo(a, b): \n c = a + b \n return c",
"role": "user"
},
{
"content": "def foo(a, b): \n# This function adds two numbers and returns the sum\n c = a + b\n return c",
"role": "assistant"
}
] | 19,658 |
[
{
"content": "Create a dictionary comprehension for the given data.\n{\"A\":1, \"B\":2, \"C\":3, \"D\":4}",
"role": "user"
},
{
"content": "Dict = {key: value for key, value in {\"A\":1, \"B\":2, \"C\":3, \"D\":4}.items()}",
"role": "assistant"
}
] | 19,659 |
[
{
"content": "Generate a Jupyter notebook to display a scatterplot of a given dataset.\nData: [[5.1, 3.5], [1.4, 2.3], [3.3, 4.3], [3.6, 2.7]]",
"role": "user"
},
{
"content": "#Import relevant packages \nimport pandas as pd \nimport matplotlib.pyplot as plt\n\n#Create dataframe\ndata = [[5.1, 3.5],... | 19,660 |
[
{
"content": "Construct a while loop in Python to print all numbers less or equal to 10.",
"role": "user"
},
{
"content": "i = 1\n\nwhile(i <= 10):\n print(i)\n i += 1",
"role": "assistant"
}
] | 19,661 |
[
{
"content": "Split a given string on the separator “:”.\nsentence = \"This:is:a:string\"",
"role": "user"
},
{
"content": "sentence.split(':') \n# Output: ['This', 'is', 'a', 'string']",
"role": "assistant"
}
] | 19,662 |
[
{
"content": "Create a set in Java from a given array of numbers.\nArray: [2, 3, 5, 4, 2, 3]",
"role": "user"
},
{
"content": "int[] arr = {2, 3, 5, 4, 2, 3};\nSet<Integer> set = new HashSet<Integer>();\nfor (int i : arr) {\n set.add(i);\n}",
"role": "assistant"
}
] | 19,663 |
[
{
"content": "Create a basic HTML page with a <title> tag and a <h1> tag.",
"role": "user"
},
{
"content": "<!DOCTYPE html>\n<html>\n<head>\n <title>Create a basic HTML page</title>\n</head>\n<body>\n <h1>Hello, World!</h1>\n</body>\n</html>",
"role": "assistant"
}
] | 19,664 |
[
{
"content": "Write a function in Python to iterate over the items in a dictionary.\ndict = {'Apple':1, 'Orange':2, 'Mango':3}",
"role": "user"
},
{
"content": "def iterate_dictionary(dict): \n for key in dict: \n print(key, ':', dict[key]) \n\niterate_dictionary(dict)",
"role": "assistant"
... | 19,665 |
[
{
"content": "Create a div in HTML with a background color of 'blue'.",
"role": "user"
},
{
"content": "<div style=\"background-color:blue;\"></div>",
"role": "assistant"
}
] | 19,666 |
[
{
"content": "What is the maximum number of columns allowed in a MySQL table?",
"role": "user"
},
{
"content": "The maximum number of columns allowed in a MySQL table is 4096.",
"role": "assistant"
}
] | 19,667 |
[
{
"content": "Create a CSS style for a <p> tag to make it bold, italic and center-aligned.",
"role": "user"
},
{
"content": "p {\n font-weight: bold;\n font-style: italic;\n text-align: center;\n}",
"role": "assistant"
}
] | 19,668 |
[
{
"content": "Create a MySQL query to update the date in the 'date' column of the 'employees' table.",
"role": "user"
},
{
"content": "UPDATE employees SET date = NOW() WHERE ID = <id>;",
"role": "assistant"
}
] | 19,669 |
[
{
"content": "Given a string, write a code to print the length of the string.\nstring = \"Hello world!\"",
"role": "user"
},
{
"content": "print(len(string))\n12",
"role": "assistant"
}
] | 19,670 |
[
{
"content": "Based on the following input array, return the largest two numbers in the array.\nnumbers = [10, 9, 8, 7, 6, 5]",
"role": "user"
},
{
"content": "# return the two largest numbers in the array\nlargestOne = max(numbers)\nnumbers.remove(largestOne)\nlargestTwo = max(numbers)\n \nprint(la... | 19,671 |
[
{
"content": "Under the given dictionary, write a code to replace the value at a given key.\ndictionary = {\n 'name': 'David',\n 'age': 20\n}\nkey = 'name'\nvalue = 'Eddie'",
"role": "user"
},
{
"content": "dictionary[key] = value",
"role": "assistant"
}
] | 19,672 |
[
{
"content": "Change the capitalization of the a text string.\nHello World",
"role": "user"
},
{
"content": "hello world",
"role": "assistant"
}
] | 19,673 |
[
{
"content": "Print the length and the middle element of the given array.\narr = [1, 2, 3, 4, 5]",
"role": "user"
},
{
"content": "# print the length of array\nprint(len(arr))\n5\n \n# print the middle element of array\nmidIndex = len(arr) // 2\nprint(arr[midIndex])\n3",
"role": "assistant"
}
... | 19,674 |
[
{
"content": "Given an integer, calculate the sum of the numbers till that number.\nnum = 7",
"role": "user"
},
{
"content": "# set the sum to 0\nsum = 0\n\n# loop from 1 to 7\nfor i in range(1, num+1):\n # add each number to \"sum\"\n sum += i\n\n# print the sum\nprint(sum)\n28",
"role": "a... | 19,675 |
[
{
"content": "What is the proper way to check if a variable of type String is empty in Bash?",
"role": "user"
},
{
"content": "if [ -z \"$var\" ]; then \n echo \"The variable is empty.\"\nfi",
"role": "assistant"
}
] | 19,676 |
[
{
"content": "Replace the following line of Javascript to appy the data-attribute to the element.\ndocument.getElementById(\"message\").append(\"My Message\");",
"role": "user"
},
{
"content": "document.getElementById(\"message\").setAttribute(\"data-text\", \"My Message\");",
"role": "assistant... | 19,677 |
[
{
"content": "How could you modify the following HTML to include a class attribute?\n<div id=\"message\">Hello World!</div>",
"role": "user"
},
{
"content": "<div id=\"message\" class=\"my-class\">Hello World!</div>",
"role": "assistant"
}
] | 19,678 |
[
{
"content": "Provide an example of using Python's range() function to generate a range of numbers.",
"role": "user"
},
{
"content": "# Print numbers from 0 to 9\nfor x in range(10):\n print(x)\n\n# Print numbers from 3 to 8\nfor x in range(3, 9):\n print(x)\n\n# Print numbers from 3 to 8 incremen... | 19,679 |
[
{
"content": "Generate a data frame with two columns: 'product' and 'price'\nproduct1: Burger\nprice1: $6\nproduct2: Fries\nprice2: $2",
"role": "user"
},
{
"content": "import pandas as pd\n\ndata = {'product':['Burger', 'Fries'], 'price':[6, 2]}\n\ndf = pd.DataFrame(data)\n\nprint(df)",
"role":... | 19,680 |
[
{
"content": "Identify the dependent and independent variables in the following equation\ny=x^2+5",
"role": "user"
},
{
"content": "Independent variable: x \nDependent variable: y",
"role": "assistant"
}
] | 19,681 |
[
{
"content": "Calculate the greatest common divisor of 36 and 24",
"role": "user"
},
{
"content": "The greatest common divisor of 36 and 24 is 12.",
"role": "assistant"
}
] | 19,682 |
[
{
"content": "Design a stack class for a language of your choice",
"role": "user"
},
{
"content": "class Stack:\n def __init__(self):\n self.stack = []\n\n def push(self, item):\n self.stack.append(item)\n\n def pop(self):\n self.stack.pop()\n\n def peek(self):\n ... | 19,683 |
[
{
"content": "Create a new list of strings of length greater than 5 from another list\n[\"apple\", \"banana\", \"carrot\"]",
"role": "user"
},
{
"content": "long_words = [word for word in [\"apple\", \"banana\", \"carrot\"] if len(word) > 5]",
"role": "assistant"
}
] | 19,684 |
[
{
"content": "Output the letter frequency from a text\nLorem ipsum dolor sit amet, consectetur adipiscing elit.",
"role": "user"
},
{
"content": "Letter frequency: \n\nL: 1\nO: 2\nR: 2\nE: 2\nM: 2\nI: 2\nP: 2\nS: 2\nU: 2\nD: 1\nA: 2\nC: 2\nT: 2\nG: 1",
"role": "assistant"
}
] | 19,685 |
[
{
"content": "Take the following pandas DataFrame, and convert it to a NumPy array.\nimport pandas as pd\n\ndf = pd.DataFrame([[1,2,3], [4,5,6], [7,8,9]])",
"role": "user"
},
{
"content": "import numpy as np\n\ndf_array = np.array(df)",
"role": "assistant"
}
] | 19,686 |
[
{
"content": "Find the value of a variable in a given environment.\nenv={'key1': 1, 'key2': 2}\nvariable=\"key2\"",
"role": "user"
},
{
"content": "value = env[variable]",
"role": "assistant"
}
] | 19,687 |
[
{
"content": "Implement a quick sort algorithm for a given array list.",
"role": "user"
},
{
"content": "def quick_sort(A):\n quick_sort_helper(A, 0, len(A) - 1)\n\ndef quick_sort_helper(A, start, end):\n if start < end:\n p_index = partition_list(A, start, end)\n quick_sort_help... | 19,688 |
[
{
"content": "Generate a list of all the divisors of a given number.",
"role": "user"
},
{
"content": "def generateDivisors(n): \n divisors = [] \n for i in range(1, n + 1): \n if n % i == 0: \n divisors.append(i) \n \n return divisors",
"role": "assistant... | 19,689 |
[
{
"content": "Given a list of numbers and a target, write an algorithm to determine if the list contains a subset that sums up to the target.",
"role": "user"
},
{
"content": "def subsetsum(arr, target):\n n = len(arr)\n dp = [[False for x in range(target + 1)] for y in range(n + 1)]\n dp[0... | 19,690 |
[
{
"content": "Write an SQL statement for creating a table called \"movies\".",
"role": "user"
},
{
"content": "CREATE TABLE movies (\n id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, \n title VARCHAR(255),\n genre VARCHAR(255),\n release_year INT,\n rating DECIMAL(2,1)\n);",
"role": "assistant"
}
... | 19,691 |
[
{
"content": "Formulate a MATLAB expression for calculating the sum of the first 10 natural numbers.",
"role": "user"
},
{
"content": "answer = sum(1:10)",
"role": "assistant"
}
] | 19,692 |
[
{
"content": "Execute a valid query using PostgreSQL for finding the title of all movies released in the year 2000.",
"role": "user"
},
{
"content": "SELECT title\nFROM movies\nWHERE release_year = 2000;",
"role": "assistant"
}
] | 19,693 |
[
{
"content": "Construct an if-else block in Java to determine if the number 15 is an even number or an odd number.\nInteger: 15",
"role": "user"
},
{
"content": "int num = 15;\n\nif(num % 2 == 0)\n{\n System.out.println(\"Even\");\n}\nelse\n{\n System.out.println(\"Odd\");\n}",
"role": "assist... | 19,694 |
[
{
"content": "Design a shell script for sorting the elements of a given array [2, 5, 1, 8, 4].\nArray elements: [2, 5, 1, 8, 4]",
"role": "user"
},
{
"content": "#!/bin/bash\n\n#array elements\narr=(2 5 1 8 4)\n\n#Sorting the array in ascending order\nfor((i=0;i<4;i++))\ndo\n for((j=0;j<4-i;j++))... | 19,695 |
[
{
"content": "Generate a Swift program for adding two numbers given as input.\nInput 1: 5\nInput 2: 10",
"role": "user"
},
{
"content": "func addTwoNumbers(number1: Int, number2: Int) -> Int {\n let result = number1 + number2\n return result\n}\n\nlet input1 = 5\nlet input2 = 10\nlet result = ... | 19,696 |
[
{
"content": "Construct a while loop in C for printing even numbers from 0 to 10.",
"role": "user"
},
{
"content": "int num = 0;\nwhile(num <= 10)\n{\n printf(\"%d \", num);\n num += 2;\n}",
"role": "assistant"
}
] | 19,697 |
[
{
"content": "Create a CSS block for changing the background color of a webpage to yellow.",
"role": "user"
},
{
"content": "body {\n background-color: yellow;\n}",
"role": "assistant"
}
] | 19,698 |
[
{
"content": "Write an Objective-C program for printing the factorial of a number 5.\nInteger number: 5",
"role": "user"
},
{
"content": "#include <stdio.h>\n\nint factorial(int n)\n{\n int result = 1;\n for (int i = 1; i <= n; i++) {\n result *= i;\n }\n return result;\n}\n\nint ... | 19,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.