messages
listlengths
2
2
conversation_id
int64
0
20k
[ { "content": "Create a function in Python that will return the maximum difference between any two numbers present in an array.", "role": "user" }, { "content": "def max_difference(arr):\n difference = 0\n for i in range(len(arr)):\n for j in range(i + 1, len(arr)):\n if arr[j...
19,700
[ { "content": "An array of integers is given, write a function to print the second largest element of the array.", "role": "user" }, { "content": "def secondLargest(arr):\n first = 0\n second = 0\n for i in range(len(arr)):\n if arr[i] > first:\n second, first = first, arr[...
19,701
[ { "content": "Write a code in Java that will get all the elements from an array that are greater than the given number.", "role": "user" }, { "content": "public static List<Integer> getElementsGreaterThan(int[] array, int number) {\n List<Integer> result = new ArrayList<>();\n for (int element...
19,702
[ { "content": "Create a Regex expression that will match strings that contain the word \"hello\".", "role": "user" }, { "content": "\\bhello\\b", "role": "assistant" } ]
19,703
[ { "content": "Given the following string, provide a function to reverse it.\n\"Hello World!\"", "role": "user" }, { "content": "def reverseString(s):\n return s[::-1]", "role": "assistant" } ]
19,704
[ { "content": "Write a SQL query that will get the name, age, and current salary of all employees who are older than 30.", "role": "user" }, { "content": "SELECT name, age, current_salary\nFROM employees\nWHERE age > 30", "role": "assistant" } ]
19,705
[ { "content": "Write a code in Python that will take a string as input and return it with the words in reverse order.", "role": "user" }, { "content": "def reverseWords(s):\n words = s.split(\" \")\n words.reverse()\n return \" \".join(words)", "role": "assistant" } ]
19,706
[ { "content": "Construct a loop through this string of characters to check for the letter ‘x’. Report what the loop index was when the letter ‘x’ was found.\nstring = \"abcedfghijx\"", "role": "user" }, { "content": "string = \"abcedfghijx\"\n\nfor idx, char in enumerate(string):\n if char == 'x':...
19,707
[ { "content": "Write a code to generate a list of numbers from 10 to 20 (inclusive).", "role": "user" }, { "content": "list_nums = [i for i in range(10, 21)]", "role": "assistant" } ]
19,708
[ { "content": "Suggest a function to convert a given tuple of strings into a dictionary.", "role": "user" }, { "content": "def tuple_to_dict(tup):\n return {tup[i] : tup[i+1] for i in range(0, len(tup), 2)}", "role": "assistant" } ]
19,709
[ { "content": "Suggest a data structure to store the student details for a school.", "role": "user" }, { "content": "A dictionary could be used to store the student details. Each key could be the student's name, and each value could be a tuple containing the student's age, grade and classes.\n\nstude...
19,710
[ { "content": "Write a regular expression to match a 4 digit zip code.", "role": "user" }, { "content": "import re\n\n# Zip code should consist of four digits.\nzip_code_regex = re.compile(r'\\d{4}')", "role": "assistant" } ]
19,711
[ { "content": "Create a DynamoDB table called \"Users\" with a primary key as \"UserID\".", "role": "user" }, { "content": "aws dynamodb create-table --table-name Users --attribute-definitions \nAttributeName=UserID,AttributeType=S \n--key-schema AttributeName=UserID,KeyType=HASH \n--provisioned-thro...
19,712
[ { "content": "Create a program that takes two inputs, an array of strings and an array of integers. Output an array with the strings at the same indices as the integers.\nString[] strings = {\"cat\", \"dog\", \"bird\", \"fish\"};\n int[] indices = {1, 0, 3, 2};", "role": "user" }, { "content": "S...
19,713
[ { "content": "Recreate a function that sorts the elements of an array using bubble sort.\nint[] array = {4, 3, 6, 5, 1, 2};", "role": "user" }, { "content": "void bubbleSort(int array[]) {\n int temp;\n for(int i = 0; i < array.length; i++) {\n for(int j = 0; j < array.length - 1; j++) {\n if(arr...
19,714
[ { "content": "Given an array with negative and positive numbers, create a function to find the smallest positive number inside the array.\nint[] array = {-3, -2, -1, 1, 2, 3, 4};", "role": "user" }, { "content": "int smallestPositive = Integer.MAX_VALUE;\nfor (int i = 0; i < array.length; i++) {\n i...
19,715
[ { "content": "Create a code that creates a 3D array of size 4x4x4.", "role": "user" }, { "content": "int[][][] array3D = new int[4][4][4];", "role": "assistant" } ]
19,716
[ { "content": "Write a SQL query that finds the average of a given table's \"Salary\" column.", "role": "user" }, { "content": "SELECT AVG(Salary) FROM Employees;", "role": "assistant" } ]
19,717
[ { "content": "Write an SQL query that calculates the total order value for each delivery zone in the ‘zones’ table.", "role": "user" }, { "content": "SELECT zone, SUM(price*quantity) AS 'Total Order Value' \nFROM orders JOIN zones ON orders.zone_id = zones.zone_id\nGROUP BY zone;", "role": "assi...
19,718
[ { "content": "Create a bash script that generates a random 3 letter string with no duplicates in it.", "role": "user" }, { "content": "#!/bin/bash\nTMP_STR=\"\"\n\nfor i in {1..3}\ndo\n RANDOM_NUM=$((RANDOM % 26 + 65))\n CHAR=$(printf \"\\x$(printf %x $RANDOM_NUM)\")\n while [[ $TMP_STR =~ $CHAR ...
19,719
[ { "content": "Write a sql query that takes the maximum of a particular column\nTable: employees\nColumns: name, salary", "role": "user" }, { "content": "SELECT MAX(salary) FROM employees;", "role": "assistant" } ]
19,720
[ { "content": "Create a machine learning model in Python to predict the total surface area of a cube given its side length\nside_length = 3", "role": "user" }, { "content": "import numpy as np\nfrom sklearn.linear_model import LinearRegression \n\n# Data\nX_train = np.array([1, 2, 3, 4, 5]).reshape(-...
19,721
[ { "content": "Correct the following C++ code by adding missing syntax.\nint a;\nif (a == 0", "role": "user" }, { "content": "int a;\nif (a == 0) {\n\n}", "role": "assistant" } ]
19,722
[ { "content": "Write a regular expression in JavaScript to check the validity of an email.", "role": "user" }, { "content": "/^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$/", "role": "assistant" } ]
19,723
[ { "content": "Write a Ruby function that takes an array as input and returns a new array with only unique elements\n[1, 2, 2, 3, 4, 5]", "role": "user" }, { "content": "def uniq_array(arr)\n return arr.uniq \nend", "role": "assistant" } ]
19,724
[ { "content": "Create a bash script to create a folder with a given name\nfolder_name = my_folder", "role": "user" }, { "content": "#!/bin/bash\n\nfolder_name=\"my_folder\"\nmkdir $folder_name", "role": "assistant" } ]
19,725
[ { "content": "Create a HTML page that takes two text strings as inputs and outputs the longest one.", "role": "user" }, { "content": "<html>\n <head>\n <title>Input and Compare Strings</title>\n </head>\n <body>\n Enter two strings:\n <input type=\"text\" id=\"str1\" />\n <input type=...
19,726
[ { "content": "In Java, write a program that prints a certain phrase five times.", "role": "user" }, { "content": "public class PrintPhrase {\n public static void main(String[] args) {\n for (int i = 0; i < 5; i++) {\n System.out.println(\"Hello world!\");\n }\n }\n}", ...
19,727
[ { "content": "Produce a regex pattern to validate a US phone number format", "role": "user" }, { "content": "^\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*$", "role": "assistant" } ]
19,728
[ { "content": "Write a JavaScript statement to extract the last four characters from the string\nThis is a sample string.", "role": "user" }, { "content": "var lastFour = myString.slice(-4);", "role": "assistant" } ]
19,729
[ { "content": "Compose an R expression to determine the median of a vector", "role": "user" }, { "content": "median(x)", "role": "assistant" } ]
19,730
[ { "content": "Write a SQL query to generate a table that contains the number of customers per county", "role": "user" }, { "content": "SELECT county, COUNT(*) AS 'Number of Customers'\nFROM Customers\nGROUP BY county;", "role": "assistant" } ]
19,731
[ { "content": "Edit this code to fix the bug in the program\ndef print_longest_word(words):\n longest_word = \"\"\n for word in words:\n if len(word) > len(longest_word):\n longest_word = word\n print(longest_word)\nwords = [\"hello\", \"cat\"]\nprint_longest_word(words)", "role": "user" }, { "conten...
19,732
[ { "content": "Print the character at the specified index in a given string.\ns = \"Hello World!\"\nindex = 5", "role": "user" }, { "content": "s = \"Hello World!\"\nindex = 5\n\nprint(\"Character at index\", index, \"is:\", s[index])\n\nOutput: Character at index 5 is: W", "role": "assistant" ...
19,733
[ { "content": "Create a function to classify the following sentence into \"positive\" or \"negative\".\nThe movie was bad", "role": "user" }, { "content": "def classify_sentence(sentence):\n if \"bad\" in sentence:\n return \"negative\"\n else:\n return \"positive\"\n\n# Driver code\nsentence...
19,734
[ { "content": "Create a function in Python that takes one parameter, a list, and outputs the list in reverse.\nmyList = [1, 2, 3, 4]", "role": "user" }, { "content": "def reverseList (list): \n list.reverse() \n return list\n \nreverseList(myList) # Returns [4, 3, 2, 1]", "role": "assistant" ...
19,735
[ { "content": "With a PHP script, compare two numerical values and return the largest of the two.\n$x = 9;\n$y = 12;", "role": "user" }, { "content": "if ($x > $y) \n echo $x;\nelse\n echo $y;", "role": "assistant" } ]
19,736
[ { "content": "Write a MySQL query to select all the products that have a price greater than 10.", "role": "user" }, { "content": "SELECT * FROM products WHERE price > 10;", "role": "assistant" } ]
19,737
[ { "content": "With a Java program, convert a string to all lowercase letters.\nmyString = \"HeLlO WoRlD\"", "role": "user" }, { "content": "String lowerString = myString.toLowerCase(); \nSystem.out.println(lowerString); // Outputs \"hello world\"", "role": "assistant" } ]
19,738
[ { "content": "You are given a list of numbers. Construct a for loop to filter out the odd numbers from the list.\narr = [1,2,3,4,5]", "role": "user" }, { "content": "odds = []\nfor num in arr:\n if num % 2 == 1:\n odds.append(num)\nprint(odds)", "role": "assistant" } ]
19,739
[ { "content": "Generate a random password that complies with certain conditions.", "role": "user" }, { "content": "import random\nimport string\n\ndef generate_password(length):\n password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(length))\n if any(char.islowe...
19,740
[ { "content": "Create a script to transpose a matrix.\nmatrix = [[1,2,3],[4,5,6],[7,8,9]]", "role": "user" }, { "content": "def transpose_matrix(matrix):\n transposedMatrix = [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0])) ]\n return transposedMatrix\n\ntransposedMatr...
19,741
[ { "content": "Initialize a list of length n using an input n.\nn = 10", "role": "user" }, { "content": "my_list = [0] * n\nprint(my_list)", "role": "assistant" } ]
19,742
[ { "content": "Write a RegEx to match all numeric strings that start with 6 and contain 4 characters.", "role": "user" }, { "content": "^6\\d{3}$", "role": "assistant" } ]
19,743
[ { "content": "Create a function to convert a given word to title case.", "role": "user" }, { "content": "def to_title_case(word):\n return word[0].upper() + word[1:].lower()", "role": "assistant" } ]
19,744
[ { "content": "You are given a matrix. Construct a for loop to check if any of the elements in the matrix is 0.\nmatrix = [[1,2,3],[4,0,6],[7,8,9]]", "role": "user" }, { "content": "def check_zero(matrix):\n for row in matrix:\n for num in row:\n if num == 0:\n ret...
19,745
[ { "content": "Create a regular expression to match the pattern of a 4-digit credit card number such as '1234 5678 9012 3456'.", "role": "user" }, { "content": "import re\npattern = re.compile(r'^[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}$')", "role": "assistant" } ]
19,746
[ { "content": "Reverse the words of a given sentence but keep the order of the words intact.\nI am a programmer", "role": "user" }, { "content": "def reverse_words(sentence):\n words = sentence.split(' ')\n reversed_words = [word[::-1] for word in words]\n return ' '.join(reversed_words)\n\n...
19,747
[ { "content": "Create a program to convert a bi-dimensional array into a single array.\n[[1, 2], [3, 4]]", "role": "user" }, { "content": "def flatten_array(array):\nresult = []\nfor sub_array in array:\n result.extend(sub_array)\nreturn result\n\nprint(flatten_array([[1, 2], [3, 4]])) # Outputs: ...
19,748
[ { "content": "Find the two elements in a given array that sums up to the target number.\n[1, 8, 10, 12], target = 18", "role": "user" }, { "content": "def two_sum_elements(arr, target):\n for i in range(len(arr)):\n for j in range(i + 1, len(arr)):\n if arr[i] + arr[j] == target...
19,749
[ { "content": "Output the word which has maximum frequency in a given string.\nThe sun has set and the moon has risen.", "role": "user" }, { "content": "the", "role": "assistant" } ]
19,750
[ { "content": "Given an array, reverse the elements inside it so that the first element becomes the last and vice versa.\n[1, 2, 3, 4]", "role": "user" }, { "content": "[4, 3, 2, 1]", "role": "assistant" } ]
19,751
[ { "content": "Parse a string of words and output an array containing only the uppercase words.\n\"I Love Coding\"", "role": "user" }, { "content": "['I', 'LOVE', 'CODING']", "role": "assistant" } ]
19,752
[ { "content": "Given an array containing integers, calculate the sum of the elements in each row and print the result.\n[[1, 2, 3], [4, 5, 6]]", "role": "user" }, { "content": "[6, 15]", "role": "assistant" } ]
19,753
[ { "content": "Create a query that displays the employees who are completed more than 20 years in the company.", "role": "user" }, { "content": "SELECT * FROM employees WHERE years_in_company > 20;", "role": "assistant" } ]
19,754
[ { "content": "Automatically reformat the following code to be more readable:\nfor (int i=0;i<n;i++){int j=0;System.out.println(\"The value of j is: \"+j);", "role": "user" }, { "content": "for (int i = 0; i < n; i++) {\n int j = 0;\n System.out.println(\"The value of j is: \" + j);\n}", "r...
19,755
[ { "content": "Write a SQL query to list the salary of all employees as a percentage of the salary of the highest paid employee.", "role": "user" }, { "content": "SELECT name, (salary / (SELECT MAX(salary) FROM employee)) * 100 AS salary_percentage\nFROM employee;", "role": "assistant" } ]
19,756
[ { "content": "Write a function that given a list of unique integers, returns the sum of the non-duplicated integer elements.\n[1, 2, 2, 3, 4, 5, 6]", "role": "user" }, { "content": "def sumNonDuplicates(arr):\n sum = 0\n for num in arr:\n if arr.count(num) == 1:\n sum += num\...
19,757
[ { "content": "Output an array with all the prime numbers between 2 and n.\n6", "role": "user" }, { "content": "[2, 3, 5]", "role": "assistant" } ]
19,758
[ { "content": "Create an algorithm that takes two numbers a and b and returns the largest number.\na = 5, b = 6", "role": "user" }, { "content": "\"\"\"\nAn algorithm that takes two numbers a and b and returns the largest number\n\"\"\"\n\ndef get_largest_number(a, b):\n if (a > b):\n retur...
19,759
[ { "content": "Given a string, print all its permutations.\nbritish", "role": "user" }, { "content": "\"\"\"\nGiven a string, print all its permutations\n\"\"\"\ndef permute(string):\n if len(string) == 1:\n return string\n permutations = []\n for i,c in enumerate(string):\n fo...
19,760
[ { "content": "Create a class called \"Vector\" with x and y coordinates.", "role": "user" }, { "content": "\"\"\"\nCreate a class called \"Vector\" with x and y coordinates\n\"\"\"\nclass Vector:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\nif __name__ == \"__main__\":\n...
19,761
[ { "content": "Write a function that takes a sentence and returns the reversed version of that sentence.\nHello, world!", "role": "user" }, { "content": "\"\"\"\nWrite a function that takes a sentence and returns the reversed version of that sentence\n\"\"\"\n\ndef reverse_sentence(sentence):\n wo...
19,762
[ { "content": "Design a simple calculator program using a switch statement.", "role": "user" }, { "content": "\"\"\"\nDesign a simple calculator program using a switch statement\n\"\"\"\n\ndef calculator(operator, x, y):\n switch = {\n '+': x + y,\n '-': x - y,\n '*': x * y,\n...
19,763
[ { "content": "Implement a sorting algorithm to sort a given array of size 10.\narray: [2, 3, 5, 7, 1, 4, 6, 9, 8, 0]", "role": "user" }, { "content": "void sort(int array[], int arraySize) { \n for (int i = 0; i < arraySize-1; i++) \n for (int j = 0; j < arraySize-i-1; j++) \n ...
19,764
[ { "content": "Generate HTML table with a given list of dictionaries.\n[{'name': 'John', 'age': 20}, {'name': 'Alice', 'age': 22}]", "role": "user" }, { "content": "<table>\n <tr>\n <th>Name</th>\n <th>Age</th>\n </tr>\n <tr>\n <td>John</td>\n <td>20</td>\n </tr>\n <tr>\n <td>Alic...
19,765
[ { "content": "Design a function in Ruby to calculate the exponent of a given base and exponent.", "role": "user" }, { "content": "def exponent(base, exp)\n result = 1\n exp.times { result *= base }\n result\nend", "role": "assistant" } ]
19,766
[ { "content": "Format this list such that each element is in a new line.\nlist_of_numbers = [1,2, 3, 4, 5]", "role": "user" }, { "content": "\"\"\"\nFormat this list such that each element is in a new line\n\"\"\"\n\nlist_of_numbers = [1,2, 3, 4, 5]\n\n# Format the list such that each element is in a...
19,767
[ { "content": "Create a code to sort this list in a descending order\nmy_list = [1,9,3,5,7]", "role": "user" }, { "content": "\"\"\"\nSort this list in a descending order\n\"\"\"\n\nmy_list = [1,9,3,5,7]\n\n# Sort the list in a descending order\nmy_list.sort(reverse=True)\nprint(my_list)", "role"...
19,768
[ { "content": "Calculate the sum of the elements in this list.\nmy_list = [2,5,4,7,5]", "role": "user" }, { "content": "\"\"\"\nCalculate the sum of the elements in this list\n\"\"\"\n\nmy_list = [2,5,4,7,5]\n\n# Calculate the sum of the elements in this list\ntotal = 0\nfor num in my_list:\n tota...
19,769
[ { "content": "Add 'excellent' as the last element in this list.\nsports_list = ['soccer', 'rugby', 'hockey']", "role": "user" }, { "content": "\"\"\"\nAdd 'excellent' as the last element in this list\n\"\"\"\n\nsports_list = ['soccer', 'rugby', 'hockey']\n\n# Add 'excellent' as the last element in t...
19,770
[ { "content": "Change the value of the second element of this list to 'cricket'.\nsports_list = ['soccer', 'rugby', 'hockey']", "role": "user" }, { "content": "\"\"\"\nChange the value of the second element of this list to 'cricket'\n\"\"\"\n\nsports_list = ['soccer', 'rugby', 'hockey']\n\n# Change t...
19,771
[ { "content": "Create a python dictionary consisting of the names of the seven dwarfs and a list of their ages.", "role": "user" }, { "content": "\"\"\"\nCreate a python dictionary consisting of the names of the seven dwarfs and a list of their ages\n\"\"\"\n\ndwarfs = {\"Doc\": 84, \n \"Gru...
19,772
[ { "content": "Extend the range from 25 to 35.\nmy_list = list(range(25))", "role": "user" }, { "content": "\"\"\"\nExtend the range from 25 to 35\n\"\"\"\n\nmy_list = list(range(25, 36))\nprint(my_list)", "role": "assistant" } ]
19,773
[ { "content": "Delete the last three elements from this list.\nmy_list = [1, 4, 6, 7, 6, 8, 9]", "role": "user" }, { "content": "\"\"\"\nDelete the last three elements from this list\n\"\"\"\n\nmy_list = [1, 4, 6, 7, 6, 8, 9]\n\n# Delete the last three elements from this list\nmy_list = my_list[:-3]\...
19,774
[ { "content": "Count the length of this string.\nmy_string = 'Hello World!'", "role": "user" }, { "content": "\"\"\"\nCount the length of this string\n\"\"\"\n\nmy_string = 'Hello World!'\n\n# Count the length of this string\nlength = len(my_string)\nprint(length)", "role": "assistant" } ]
19,775
[ { "content": "Classify the following statement as an example of a Boolean expression: \"2 * 3 - 5 > 11\".\n2 * 3 - 5 > 11", "role": "user" }, { "content": "True", "role": "assistant" } ]
19,776
[ { "content": "Create a lambda function in Python that collects all the numbers between 0 and 10 that are divisible by 3.", "role": "user" }, { "content": "lambda x: [x for x in range(0, 11) if x % 3 == 0]", "role": "assistant" } ]
19,777
[ { "content": "Compute the average of the following numbers: 45, 20, 15, 100, 75.", "role": "user" }, { "content": "54", "role": "assistant" } ]
19,778
[ { "content": "Write a C++ code snippet to create an infinite loop.", "role": "user" }, { "content": "while (true) {\n //infinite loop code here\n}", "role": "assistant" } ]
19,779
[ { "content": "Write a Python code snippet to generate a list of the first five powers of the number 2.", "role": "user" }, { "content": "[2**0, 2**1, 2**2, 2**3, 2**4]", "role": "assistant" } ]
19,780
[ { "content": "Write a regular expression to match the following sentence: \"Mary had a little lamb\".", "role": "user" }, { "content": "/Mary\\s+had\\s+a\\s+little\\s+lamb/", "role": "assistant" } ]
19,781
[ { "content": "Compile the following C++ code:\n\n#include <iostream>\nusing namespace std;\n\nint main() {\n cout << \"Hello World!\";\n return 0;\n}", "role": "user" }, { "content": "g++ -o [filename] [filename].cpp", "role": "assistant" } ]
19,782
[ { "content": "Write a HTML form to take in two user inputs and display their sum.", "role": "user" }, { "content": "<html>\n <body>\n <form>\n Enter Number 1: <input type=\"text\" name=\"num1\" /> <br />\n Enter Number 2: <input type=\"text\" name=\"num2\" /> <br />\n <input type=...
19,783
[ { "content": "Modify the following Keras model to add one 1D convolutional layer before the last layer.\nmodel = Sequential()\nmodel.add(Dense(64, activation='relu', input_dim=100))\nmodel.add(Dense(1, activation='sigmoid'))", "role": "user" }, { "content": "model = Sequential()\nmodel.add(Dense(64,...
19,784
[ { "content": "Write a JavaScript function that takes a string as an argument and produces a new string with the duplicated characters removed.", "role": "user" }, { "content": "function removeDuplicates(str) {\n let result = '';\n let seen = new Set();\n\n for (let char of str) {\n i...
19,785
[ { "content": "Create a JavaScript dictionary object using the following data.\napple: red\norange: orange\nbanana: yellow", "role": "user" }, { "content": "const fruits = {\n apple: 'red',\n orange: 'orange',\n banana: 'yellow'\n};", "role": "assistant" } ]
19,786
[ { "content": "Create an HTML form with two input fields to take two numbers and a submit button to submit the form.", "role": "user" }, { "content": "<form>\n <input type=\"number\" name=\"num1\">\n <input type=\"number\" name=\"num2\">\n <input type=\"submit\" value=\"Submit\">\n</form>", "r...
19,787
[ { "content": "Write a regular expression to match a string that contains the word \"Hello\" at the start of the string.", "role": "user" }, { "content": "^Hello.*", "role": "assistant" } ]
19,788
[ { "content": "Create a function to take two integers and return the larger one.", "role": "user" }, { "content": "def larger(num1, num2):\n \"\"\"Takes two integers and returns the larger one.\n\n Args:\n num1 (int): The first integer.\n num2 (int): The second integer.\n\n Ret...
19,789
[ { "content": "Using GraphQL, write a query to get name, age and address of all instructors in a training center.", "role": "user" }, { "content": "query {\n instructors {\n name\n age\n address\n }\n}", "role": "assistant" } ]
19,790
[ { "content": "Implement a function, sumOfSquares, that takes two integers and calculates the sum of their squares.", "role": "user" }, { "content": "def sumOfSquares(num1, num2):\n return num1**2 + num2**2", "role": "assistant" } ]
19,791
[ { "content": "Write a web scraper using BeautifulSoup to extract a list of tweets from a site.\nTarget site: https://twitter.com/", "role": "user" }, { "content": "import requests\nfrom bs4 import BeautifulSoup\n\nwebsite_url = requests.get('https://twitter.com/').text\n\nsoup = BeautifulSoup(websit...
19,792
[ { "content": "Automate calculations in Excel by writing a VBA program to calculate the sum of two columns.", "role": "user" }, { "content": "Sub columns_sum()\n Dim cell As Range\n Dim first_sum As Integer, second_sum As Integer\n \n For Each cell In Range(\"A1:A5\")\n first_sum = first_sum + ...
19,793
[ { "content": "What is the maximum length of a URL as defined in RFC 2396?", "role": "user" }, { "content": "According to RFC 2396, the maximum length of a URL is 2048 characters.", "role": "assistant" } ]
19,794
[ { "content": "Use CSS to create a dark mode version of the following website.\nLink to a website: https://example.com", "role": "user" }, { "content": "body {\n background-color: #2d2d2d;\n color: #ffffff;\n}\n\n// Set the typeface\nbody {\n font-family: \"Open Sans\", Helvetica, sans-serif;\n}\n...
19,795
[ { "content": "Update the following JSON array to increment the \"age\" value of every user by 5 years.\n[\n {\n \"name\": \"Alice\",\n \"age\": 25\n },\n {\n \"name\": \"Bob\",\n \"age\": 30\n }\n]", "role": "user" }, { "content": "[\n {\n \"name\": \"Alice\",\n \"age\": 30\n ...
19,796
[ { "content": "Write a MySQL query to find the names of all the students who took both math and science classes.", "role": "user" }, { "content": "SELECT students.name\nFROM students\nWHERE EXISTS (\n SELECT 1 FROM classes\n WHERE classes.student_id = students.id\n AND classes.subject IN ('math','...
19,797
[ { "content": "Using MapReduce, calculate the average age of the users in a given dataset.", "role": "user" }, { "content": "map(key, value)\n{\n age = value.age\n emit(null, age)\n}\n\nreduce(key, values)\n{\n total = 0\n count = 0\n foreach (value in values)\n {\n total = total + value\n ...
19,798
[ { "content": "Generate a random string containing 10 lowercase alphabets using JavaScript.", "role": "user" }, { "content": "let randomString = '';\nfor (let i=0;i<10;i++) {\n randomString += String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1)) + 97);\n}\nconsole.log(randomString);", ...
19,799