system
stringclasses
1 value
tools
listlengths
0
0
messages
listlengths
1
34
conversation_id
int64
0
1.2k
[]
[ { "content": "Write a function in JavaScript that listens for changes to the value of a form input field and updates a live preview div with the new content, but only if it passes a validation check (e.g., no profanity).", "role": "user" }, { "content": "Certainly! Below is a simple JavaScript funct...
0
[]
[ { "content": "Design a SQL query to find all customers who have made more than three purchases in the last month, assuming there exist tables for `customers` (with customer ID) and `purchases` (with purchase date, amount, and customer ID).", "role": "user" }, { "content": "To design a SQL query that...
1
[]
[ { "content": "Create a Python function `merge_dicts` that takes two dictionaries as input and merges them. The function should prioritize the key-value pairs from the second dictionary when there are duplicate keys.", "role": "user" }, { "content": "Certainly! Below is a Python function named `merge...
2
[]
[ { "content": "Develop a SQL query that selects the top 3 highest-earning employees in each department from a table named `employees`, assuming the table has columns for `employee_id`, `name`, `salary`, and `department`.", "role": "user" }, { "content": "To select the top 3 highest-earning employees ...
3
[]
[ { "content": "Create a Python script that connects to a publicly available API (e.g., http://jsonplaceholder.typicode.com/posts) and fetches the data. Ensure that the script parses the JSON data and outputs the title of the first post in the response.", "role": "user" }, { "content": "To connect to ...
4
[]
[ { "content": "Implement an algorithm in Python that takes a list of numbers as input and returns a new list with each number squared. For example, given `[1, 2, 3, 4]`, the output should be `[1, 4, 9, 16]`.", "role": "user" }, { "content": "Certainly! Below is a Python function that takes a list of ...
5
[]
[ { "content": "Write a function in Python that takes a string as input and checks whether the string is a palindrome (reads the same backward as forward, ignoring spaces, punctuation, and case). For instance, \"A man, a plan, a canal: Panama\" is a palindrome.", "role": "user" }, { "content": "Certai...
6
[]
[ { "content": "Design a Python function that accepts a list of integers and returns a new list with each integer squared. Ensure your function handles negative numbers and zeros correctly.\n\n```python\ndef square_list(numbers):\n squared_numbers = [number ** 2 for number in numbers]\n return squared_numbe...
7
[]
[ { "content": "Implement a Python function that takes a string as input and returns a dictionary where each key is a character in the string, and its value is the number of times the character appears in the string.\n\n```python\ndef char_frequency(s):\n frequency = {}\n for char in s:\n if char in ...
8
[]
[ { "content": "Create a Python function that generates and returns the first *n* Fibonacci numbers in a list, where *n* is a positive integer provided as input to the function.\n\n```python\ndef generate_fibonacci(n):\n fib_series = [0, 1]\n for i in range(2, n):\n next_fib = fib_series[i-1] + fib_s...
9
[]
[ { "content": "Create a Python script that establishes a connection to a PostgreSQL database using psycopg2, runs a query to fetch the last 10 records from a table named 'sales', and prints the result.", "role": "user" }, { "content": "To establish a connection to a PostgreSQL database and fetch the ...
10
[]
[ { "content": "Write a JavaScript function that takes an array of URLs, fetches data asynchronously from each URL using the Fetch API, and logs the length of each response body.", "role": "user" }, { "content": "Certainly! Below is a JavaScript function that takes an array of URLs, fetches data async...
11
[]
[ { "content": "Write a function `isomorphic_strings` in Python that checks if two given strings, `s` and `t`, are isomorphic. Two strings are isomorphic if the characters in `s` can be replaced to get `t`, ensuring that no two characters map to the same character unless they are replaced by themselves. Provide e...
12
[]
[ { "content": "Develop a Python function to check if a given string is a palindrome. The function should be case insensitive and ignore spaces.", "role": "user" }, { "content": "Certainly! Below is a Python function that checks if a given string is a palindrome, considering the requirements to be cas...
13
[]
[ { "content": "Create a Python program to sort a list of names alphabetically. Ensure your program can handle names with mixed case (e.g., \"alice\", \"Zoe\", \"bob\") by treating upper and lower case letters as equivalent.", "role": "user" }, { "content": "Certainly! Below is a Python program that s...
14
[]
[ { "content": "Write a JavaScript function that takes an array of numbers and returns the sum of the squares of those numbers. The function should work for both integer and floating point numbers.", "role": "user" }, { "content": "Certainly! Below is a JavaScript function that takes an array of numbe...
15
[]
[ { "content": "Design a SQL query to find all employees who earn more than their managers. The database contains two tables: `Employees(id, name, managerId, salary)` and `Managers(managerId, name)`. Assume each employee has only one manager.", "role": "user" }, { "content": "To find all employees who...
16
[]
[ { "content": "Design a Python script that connects to an API of your choice (for example, OpenWeatherMap API), fetches the current weather data for a specified location, and prints the temperature, humidity, and weather description.", "role": "user" }, { "content": "To create a Python script that fe...
17
[]
[ { "content": "Create a class in Python to represent a simple bank account. The class should support methods for depositing money, withdrawing money, and checking the account balance. Ensure that the account balance cannot go below zero.", "role": "user" }, { "content": "Certainly! Below is a simple ...
18
[]
[ { "content": "Implement a function in Python that generates a Fibonacci sequence using recursion and returns the n-th Fibonacci number. The Fibonacci sequence starts with 0 (0th Fibonacci) and 1 (1st Fibonacci), and each subsequent number is the sum of the previous two.", "role": "user" }, { "conten...
19
[]
[ { "content": "Write a Python function that simulates tossing a fair coin 100 times. Your function should return the total number of heads and tails.", "role": "user" }, { "content": "Certainly! To simulate tossing a fair coin 100 times in Python, you can use the `random` module, which includes a fun...
20
[]
[ { "content": "Write a Python function to merge two sorted lists into a new sorted list. The input lists will be of integers and can be of different lengths.\n\n```\ndef merge_sorted_lists(list1, list2):\n # Your code here\n```", "role": "user" }, { "content": "Certainly! Below is a Python functio...
21
[]
[ { "content": "Implement a Python function to check whether a given string is a palindrome, ignoring spaces, punctuation, and case sensitivity.", "role": "user" }, { "content": "To create a Python function that checks if a given string is a palindrome while ignoring spaces, punctuation, and case sens...
22
[]
[ { "content": "You are tasked with implementing a simple text-based calculator that can evaluate expressions containing add (‘+’), subtract (‘-’), multiply (‘*’), and divide (‘/’) operations on integers. The input will be a string representing the expression, e.g., \"3 + 5 * 2\". The program should return the re...
23
[]
[ { "content": "Create a function that takes an unsorted array of integers and returns a new array with the same integers in ascending order. Do not use the built-in sort functions; instead, implement one of the basic sorting algorithms (e.g., bubble sort, selection sort, or insertion sort).", "role": "user" ...
24
[]
[ { "content": "Design a function that can serialize a binary search tree into a string and then deserialize that string back into the original binary search tree. The serialization format is up to you but ensure it is as efficient as possible.", "role": "user" }, { "content": "To efficiently serializ...
25
[]
[ { "content": "Create a Python function that takes a list of integers and returns a new list containing just the even numbers from the original list, multiplied by 2.", "role": "user" }, { "content": "Certainly! Below is a Python function that accomplishes the task you described. This function iterat...
26
[]
[ { "content": "Design a RESTful API endpoint in Flask that takes a username and returns a welcome message containing the username.", "role": "user" }, { "content": "To design a RESTful API endpoint in Flask that takes a username and returns a welcome message containing the username, you can follow th...
27
[]
[ { "content": "Write a SQL query that selects the top 3 highest-selling products from a `sales` table that contains columns `product_id`, `product_name`, and `units_sold`.", "role": "user" }, { "content": "To select the top 3 highest-selling products based on the `units_sold` column from the `sales` ...
28
[]
[ { "content": "Write a function to compress a string using the counts of repeated characters. For example, the string `\"aabcccccaaa\"` would become `\"a2b1c5a3\"`. If the compressed string would not become smaller than the original string, your function should return the original string. You can assume the stri...
29
[]
[ { "content": "Write a recursive function to generate all the permutations of a string. The characters are unique and can be assumed to be in lowercase.", "role": "user" }, { "content": "To generate all permutations of a string recursively, we can follow a simple strategy: for each character in the s...
30
[]
[ { "content": "Design a memoization solution to calculate the nth Fibonacci number. The standard recursive approach results in a lot of repeated work. Your solution should efficiently avoid recalculating values that have already been computed.", "role": "user" }, { "content": "To efficiently calculat...
31
[]
[ { "content": "Implement a simple linear search algorithm in Python that searches for a given value within an unsorted list and returns the index of the value if found, or -1 if the value is not present in the list.", "role": "user" }, { "content": "Certainly! Below is a Python function that implemen...
32
[]
[ { "content": "Write a Python function that takes a list of numbers and returns a new list that contains each number from the original list only once. You should not use any built-in functions like `set()`.", "role": "user" }, { "content": "Certainly! To achieve this, you can iterate through the orig...
33
[]
[ { "content": "Implement a function to perform matrix multiplication between two matrices. The function should check if the matrices can be multiplied based on their dimensions and return the resulting matrix or an appropriate error message.", "role": "user" }, { "content": "To perform matrix multipl...
34
[]
[ { "content": "Create a Python script that scrapes weather data (like temperature, humidity, and wind speed) for a given city from a webpage and stores this information in a CSV file.", "role": "user" }, { "content": "Certainly! Below is a simple Python script that scrapes weather data for a given ci...
35
[]
[ { "content": "Design a RESTful API using Flask that allows storing user profiles (including name, email, and age) in memory. Ensure it supports basic CRUD (Create, Read, Update, Delete) operations for user profiles.", "role": "user" }, { "content": "To design a RESTful API using Flask for managing u...
36
[]
[ { "content": "Create a Python program to count the number of vowels in a given string using a dictionary.", "role": "user" }, { "content": "Certainly! Below is a Python program that counts the number of vowels in a given string using a dictionary. This program is designed to be case-insensitive and ...
37
[]
[ { "content": "Develop a Java method that takes an integer array as input and returns a new array without any duplicates. The order of elements must be preserved.", "role": "user" }, { "content": "To achieve the task of removing duplicates from an array while preserving the order of elements, we can ...
38
[]
[ { "content": "Write a Python function `merge_dicts` that merges two dictionaries by summing up values for keys that appear in both. Assume all values are integers.", "role": "user" }, { "content": "Certainly! Below is a Python function named `merge_dicts` that takes two dictionaries as input and ret...
39
[]
[ { "content": "tests the LLM's ability to manipulate basic data structures (dictionaries) and perform arithmetic operations on their values. It assesses understanding of iteration, key existence checks, and value updates.", "role": "user" }, { "content": "To demonstrate the ability to manipulate basi...
40
[]
[ { "content": "Implement a simple TCP server in Python that listens on localhost and echoes back any message it receives.", "role": "user" }, { "content": "To create a simple TCP echo server in Python, you can use the `socket` library. This server will listen on localhost (127.0.0.1) on a specified p...
41
[]
[ { "content": "Implement a simple encryption algorithm in Python that takes a string and a non-negative integer key as inputs, and outputs a new string where each character in the original string is shifted forward in the alphabet by the key number of positions, wrapping around to the beginning of the alphabet i...
42
[]
[ { "content": "Write a Python function to calculate the nth Fibonacci number using recursion. Ensure to include a base case to prevent infinite recursion.", "role": "user" }, { "content": "Certainly! The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones,...
43
[]
[ { "content": "Write a Python function that generates a Fibonacci sequence up to the nth number using recursion.", "role": "user" }, { "content": "To generate a Fibonacci sequence up to the nth number using recursion in Python, you can define a function that calls itself to calculate each number in t...
44
[]
[ { "content": "Create a simple RESTful API in Flask that accepts JSON data and stores it in a local file.", "role": "user" }, { "content": "To create a simple RESTful API in Flask that accepts JSON data and stores it in a local file, follow these steps. This example assumes you have Flask installed. ...
45
[]
[ { "content": "Design a Python program that takes an input string and outputs a version of the string with vowels removed.", "role": "user" }, { "content": "Certainly! Below is a simple Python program that takes an input string from the user, removes all the vowels from it, and then outputs the modif...
46
[]
[ { "content": "Implement a recursive function in Python to compute the nth Fibonacci number. Remember to include a memoization technique to optimize the recursion. \n\n**Code Snippet for Reference**:\n```\ndef fibonacci(n, memo={}):\n if n in memo:\n return memo[n]\n if n <= 2:\n return 1\n ...
47
[]
[ { "content": "Write a Python function that checks if a given string is a palindrome without using any built-in string manipulation functions. Also, ensure your solution is case-insensitive.", "role": "user" }, { "content": "To create a Python function that checks if a given string is a palindrome wi...
48
[]
[ { "content": "Develop a Python function that merges two dictionaries by adding values together if they have the same key. For keys that appear in only one dictionary, just include them in the result. Assume all values are integers.", "role": "user" }, { "content": "Certainly! Below is a Python funct...
49
[]
[ { "content": "Implement a Python function that converts a flat dictionary into a nested dictionary based on a separator in the keys, such as a period ('.'). For example, `{'a.b': 1, 'a.c': 2}` should become `{'a': {'b': 1, 'c': 2}}`.", "role": "user" }, { "content": "Certainly! Below is a Python fun...
50
[]
[ { "content": "Given an array of integers, some elements appear twice and others appear once. Implement a function to find all the elements that appear only once. Your solution should aim to have linear time complexity and no extra space usage (besides variables).", "role": "user" }, { "content": "To...
51
[]
[ { "content": "Implement the bubble sort algorithm in Python. Ensure your function takes a list of numbers as input and returns a sorted list.\n\n```python\ndef bubble_sort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j...
52
[]
[ { "content": "Consider the following Python function intended to compute the nth Fibonacci number:\n\n```python\ndef fib(n):\n if n <= 1:\n return n\n else:\n return fib(n-1) + fib(n-2)\n```", "role": "user" }, { "content": "The provided Python function `fib` is a direct implementa...
53
[]
[ { "content": "Write a simple HTML form with a user input field and a submit button. The form should collect a user's favorite color and output the color name on the same page when the submit button is clicked.", "role": "user" }, { "content": "To achieve the functionality of displaying the user's fa...
54
[]
[ { "content": "Create a Python script that reads a text file containing emails and names in the format \"name, email\\n\", and then prints out a dictionary where each key is a domain name (from the email addresses) and its value is a list of names associated with emails from that domain.", "role": "user" }...
55
[]
[ { "content": "Develop a function in C++ to calculate the nth Fibonacci number using a dynamic programming approach, minimizing the time complexity.", "role": "user" }, { "content": "Certainly! To calculate the nth Fibonacci number using a dynamic programming approach in C++, we aim to minimize the t...
56
[]
[ { "content": "Given an unsorted array of integers, write a function to return the kth largest element in the array. Do not use any built-in sort function.", "role": "user" }, { "content": "To find the kth largest element in an unsorted array without using any built-in sort function, you can use the ...
57
[]
[ { "content": "Write a Python program that simulates a simple calculator. It should take two operands and an operator (+, -, *, /) from the user and return the result.", "role": "user" }, { "content": "Certainly! Below is a simple Python program that acts as a calculator. It prompts the user for two ...
58
[]
[ { "content": "Implement a function that counts the number of inversions in an array. An inversion is a pair of indices \\((i, j)\\) such that \\(i < j\\) and \\(a[i] > a[j]\\).", "role": "user" }, { "content": "To count the number of inversions in an array efficiently, we can use a modification of t...
59
[]
[ { "content": "Write a Python function that reverses a linked list without creating a new list in memory.\n- The function should accept the head of the list as its parameter.\n- Your solution should directly manipulate the nodes’ links.", "role": "user" }, { "content": "To reverse a linked list in pl...
60
[]
[ { "content": "Design a SQL query to find the top 3 highest salaries from the `employees` table.\n- Assume the `employees` table has columns `id`, `name`, and `salary`.\n- Your query should return the names and salaries of the top 3 employees with the highest salaries.", "role": "user" }, { "content"...
61
[]
[ { "content": "Create a Python script that extracts and prints all the URLs found in a given text document.", "role": "user" }, { "content": "Certainly! Below is a simple Python script that extracts and prints all the URLs found in a given text document. This script uses the `re` module for regular e...
62
[]
[ { "content": "Design a function in JavaScript that validates if a user input is a valid email address. Display a message to the user based on the validation result.", "role": "user" }, { "content": "To design a function in JavaScript that validates if a user input is a valid email address, we can us...
63
[]
[ { "content": "Write a function in Java that calculates and returns the factorial of a number provided as input.", "role": "user" }, { "content": "Certainly! Below is a simple Java function that calculates the factorial of a given number using recursion. This method is straightforward but keep in min...
64
[]
[ { "content": "Design a Python function `merge_and_sort(list1, list2)` that merges two sorted lists (which may have different lengths) into a single sorted list. The function should not use any built-in sort or merge functions/methods but should implement the merge process manually.", "role": "user" }, {...
65
[]
[ { "content": "Implement a Python function called `rotate_array(arr, n)` that rotates an array `arr` to the right by `n` steps, where `n` is a non-negative integer. For example, rotating the array `[1, 2, 3, 4, 5]` by 2 steps would result in `[4, 5, 1, 2, 3]`. The solution should handle cases where `n` is larger...
66
[]
[ { "content": "Create a Python function that recursively calculates the Fibonacci number at a given position in the sequence, ensuring you handle input errors gracefully.", "role": "user" }, { "content": "Certainly! Below is a Python function that recursively calculates the Fibonacci number at a give...
67
[]
[ { "content": "Write a JavaScript function that validates whether a given string is a palindrome, disregarding case sensitivity and ignoring non-alphanumeric characters.", "role": "user" }, { "content": "Certainly! Below is a JavaScript function that checks if a given string is a palindrome, ignoring...
68
[]
[ { "content": "Write a function in Python that takes a list of daily stock prices (assuming it represents the price of a stock on days 1 through n) and returns the maximum profit you can achieve by buying and selling the stock once. You cannot sell a stock before you buy one.\n\n```python\ndef max_profit(prices)...
69
[]
[ { "content": "Given a binary tree, write a recursive Python function to compute the height of the tree. The height of a binary tree is the number of edges between the tree's root and its furthest leaf.\n\n```python\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n...
70
[]
[ { "content": "Write a function in Python that takes a list of strings as input and returns a new list containing only those strings that have unique characters. You should not use any additional data structures.", "role": "user" }, { "content": "Certainly! Below is a Python function that takes a lis...
71
[]
[ { "content": "Create a REST API using Flask that allows users to upload images and saves them into a local directory. The API should also be able to list all the images that have been uploaded.", "role": "user" }, { "content": "To create a REST API using Flask that allows users to upload images and ...
72
[]
[ { "content": "Design a simple machine learning model in TensorFlow or PyTorch that predicts the sentiment (positive or negative) of a given piece of text. Ensure the model is lightweight and explain your choice of architecture.", "role": "user" }, { "content": "Given the constraints, a simple yet ef...
73
[]
[ { "content": "Write a Python program that accepts a string from the user and counts the number of vowels (a, e, i, o, u) present in it using a loop.", "role": "user" }, { "content": "Certainly! Below is a simple Python program that prompts the user to input a string and then counts the number of vow...
74
[]
[ { "content": "Write a Java method that calculates and returns the factorial of a given number using iteration.", "role": "user" }, { "content": "Certainly! Below is a Java method that calculates the factorial of a given number using iteration. The factorial of a number n is the product of all positi...
75
[]
[ { "content": "Design a Python function that implements a stack using two queues. The stack should support basic operations like push, pop, and top.", "role": "user" }, { "content": "To implement a stack using two queues, we can use two approaches: making either the push or the pop operation costly. ...
76
[]
[ { "content": "Implement a Python function to recursively reverse a linked list. Ensure your solution efficiently handles both the head pointer and next pointers within each node.", "role": "user" }, { "content": "To recursively reverse a linked list in Python, you'll need to define a function that t...
77
[]
[ { "content": "Implement a function in Python that performs matrix multiplication on two 2D arrays (matrices) given as input. Assume that the matrix dimensions are compatible for multiplication.\n\n```python\ndef matrix_multiply(matrix1, matrix2):\n result = [[0 for _ in range(len(matrix2[0]))] for _ in range...
78
[]
[ { "content": "Imagine you are given a graph represented as an adjacency list and two nodes (start and end). Implement a Python function that checks whether there is a path from the start node to the end node.\n\n```python\ndef is_path_exist(graph, start, end, visited=None):\n if visited is None:\n vis...
79
[]
[ { "content": "Implement a Python function `merge_intervals()` that takes a list of intervals as input and merges all overlapping intervals. The input list contains intervals as pairs of integers, e.g., `[(1, 3), (2, 4), (5, 7), (6, 8)]`.", "role": "user" }, { "content": "To implement the `merge_inte...
80
[]
[ { "content": "Create a Python function that takes a list of integers and returns a new list containing only the prime numbers found in the input list.\n\n```python\ndef filter_primes(num_list):\n def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
81
[]
[ { "content": "Implement a REST API in Flask that accepts JSON payload with two numbers and returns their sum.\n\n```python\nfrom flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n@app.route('/add', methods=['POST'])\ndef add_numbers():\n data = request.get_json()\n sum_result = data['num1']...
82
[]
[ { "content": "Write a function in JavaScript to validate whether a given string is a valid JSON format or not. It should return true if the string is a valid JSON, otherwise false.\n\n```javascript\nfunction isValidJSON(testString) {\n try {\n JSON.parse(testString);\n return true;\n } catch...
83
[]
[ { "content": "Create a function in Python to merge two sorted lists into a single sorted list without using the built-in sort methods or any external libraries.", "role": "user" }, { "content": "Certainly! Below is a Python function that merges two sorted lists into a single sorted list. This functi...
84
[]
[ { "content": "Write a recursive function in JavaScript to calculate the nth Fibonacci number without using any loops. Assume n is always a positive integer.", "role": "user" }, { "content": "Certainly! The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding on...
85
[]
[ { "content": "Design a SQL query to find the second highest salary from the \"Employee\" table without using the LIMIT or TOP clause. Assume the table has columns \"Id\", \"Name\", and \"Salary\".", "role": "user" }, { "content": "To find the second highest salary from the \"Employee\" table without...
86
[]
[ { "content": "Write a Python program that takes a list of numbers and returns a new list with each number doubled. Make sure to include error handling for non-numeric values in the list.", "role": "user" }, { "content": "Certainly! Below is a Python program that takes a list of numbers, doubles each...
87
[]
[ { "content": "Implement a JavaScript function that takes an input string and compresses it using the basic run-length encoding algorithm. For instance, the input \"aaaabcccaa\" should result in \"4a1b3c2a\".", "role": "user" }, { "content": "Certainly! Below is a simple JavaScript function that impl...
88
[]
[ { "content": "Write a function in Python that checks if a given string is a palindrome. The function should have a linear time complexity (O(n)) and ignore spaces, punctuation, and case sensitivity.\n\n```python\ndef is_palindrome(s):\n # Your implementation here\n```", "role": "user" }, { "conte...
89
[]
[ { "content": "Implement a Queue using two Stacks in Python. The queue should support the following operations with their respective time complexities: enqueue (O(1)), dequeue (Amortized O(1)), and isEmpty (O(1)).\n\n```python\nclass Queue:\n def __init__(self):\n # Your implementation here\n \n ...
90
[]
[ { "content": "Write a recursive function in Python to generate all possible subsets of a given set (or list). The subsets should include the empty set and have no duplicates.\n\n```python\ndef generate_subsets(s):\n # Your implementation here\n```", "role": "user" }, { "content": "To generate all...
91
[]
[ { "content": "Implement a function in Python that merges two dictionaries by adding values together for overlapping keys and keeping non-overlapping keys as they are. Assume all values are integers.\n\n```python\ndef merge_dictionaries(dict1, dict2):\n # Your implementation here\n```", "role": "user" }...
92
[]
[ { "content": "Create a Python program that takes a list of integers as input and returns a new list with each original element squared, while filtering out the even squares, keeping only the odd squares.", "role": "user" }, { "content": "Certainly! Below is a Python program that accomplishes the tas...
93
[]
[ { "content": "Write a JavaScript function that asynchronously fetches JSON data from a given URL and logs each item's name property to the console. Assume the JSON is an array of objects where each object has a 'name' key.", "role": "user" }, { "content": "Certainly! Below is a simple JavaScript fun...
94
[]
[ { "content": "Design a SQL query that retrieves all orders from the 'orders' table made in the last 30 days, including the order ID, customer name, and total amount. Assume the relevant columns are 'order_id', 'customer_name', 'order_date', and 'total_amount'.", "role": "user" }, { "content": "To de...
95
[]
[ { "content": "Create a Python function that takes a list of numbers as input and returns a new list containing only the prime numbers found in the original list.", "role": "user" }, { "content": "Certainly! Below is a Python function named `filter_primes` that takes a list of numbers as input and re...
96
[]
[ { "content": "Write a JavaScript function that takes an array of strings and returns a new array containing only those strings that are palindromes (words that read the same backward as forward).", "role": "user" }, { "content": "Certainly! Below is a JavaScript function that filters an array of str...
97
[]
[ { "content": "Write a Python function that accepts a list of integers and returns a new list with each integer squared, only if the integer is even. The function should preserve the order of the original list.", "role": "user" }, { "content": "Certainly! Below is a Python function that takes a list ...
98
[]
[ { "content": "Implement a recursive function in Python to compute the factorial of a number. Ensure that the function includes error handling to manage negative inputs by raising an exception.", "role": "user" }, { "content": "Certainly! Below is a Python function that computes the factorial of a nu...
99