messages listlengths 2 2 |
|---|
[
{
"role": "user",
"content": "Create a function that takes two integers, A and B, and returns the largest common divisor between A and B. Your solution should not use any built-in functions or libraries for calculating the greatest common divisor."
},
{
"role": "system",
"content": "Here is a fu... |
[
{
"role": "user",
"content": "Write a function that takes an array and returns the number of elements that are even and greater than 10.\narr = [1, 5, 7, 4, 9, 17]"
},
{
"role": "system",
"content": "Here's the function in Python:\n\n```python\ndef count_even_greater_than_10(arr):\n count = 0... |
[
{
"role": "user",
"content": "What is the best way to check if a given input is a prime number within a given range?"
},
{
"role": "system",
"content": "There are multiple approaches to check if a given input is a prime number within a given range. Here's one commonly used method called the tria... |
[
{
"role": "user",
"content": "Verify if a given string is a valid email address and return the domain name of the email address.\nemail = \"email@example.com\"\n\n# Explanation #\nIn addition to checking if the string is a valid email address, the solution should also extract and return the domain name of t... |
[
{
"role": "user",
"content": "Generate a code to evaluate a mathematical expression of the form a * (b + c), where a, b, and c are positive integers. The code should handle cases where a, b, and c can have values ranging from 1 to 100."
},
{
"role": "system",
"content": "Here is a code in Python... |
[
{
"role": "user",
"content": "In Python, how could you print a list from the last element to the first element, without using any built-in functions or methods such as `reverse()` or `[::-1]`?"
},
{
"role": "system",
"content": "One possible way to print a list from the last element to the first... |
[
{
"role": "user",
"content": "Count the number of occurrences of a given string in another string in Python, while also ignoring case sensitivity.\nstring1 = 'A quick brown fox jumps over the lazy dog.'\nstring2 = 'dog'\n\nAdditional Requirement: The solution should be case-insensitive and count occurrences... |
[
{
"role": "user",
"content": "Given a variable arr containing integers, write python code to remove all duplicate elements from the array and return the new array. The time complexity of your solution should be O(n), where n is the length of the array.\n\narr = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6]"
},
{
"... |
[
{
"role": "user",
"content": "Create a dictionary in Python whose keys are the integers from 1 to 10 and whose values are the squares of the keys. The keys and values must be stored in descending order based on the square values."
},
{
"role": "system",
"content": "To create a dictionary in Pyth... |
[
{
"role": "user",
"content": "Write an algorithm to find the missing number in an array of n consecutive integers in Python. The array may contain duplicate numbers.\n\narr = [1, 2, 2, 3, 3, 5, 6, 7, 7, 8]\n\nNote: The array may have duplicates and the missing number can also be a duplicate."
},
{
"... |
[
{
"role": "user",
"content": "Given a list of strings, write a program to return a new list of all strings which have a length greater than 4 and contain at least one uppercase letter in Python.\nlst = ['cat', 'Dog', 'apple', 'banana']"
},
{
"role": "system",
"content": "Here is the solution to ... |
[
{
"role": "user",
"content": "Create a for loop for printing all the alphabets in the lowercase in reverse order."
},
{
"role": "system",
"content": "Here is a for loop that prints all the lowercase alphabets in reverse order:\n\n```python\nfor letter in range(ord('z'), ord('a')-1, -1):\n pri... |
[
{
"role": "user",
"content": "Edit the given code snippet and make it run in O(N) time complexity, while also ensuring that the algorithm uses constant space complexity. Additionally, the solution should be implemented using a recursive approach."
},
{
"role": "system",
"content": "To make the c... |
[
{
"role": "user",
"content": "Create an array of elements that are the cubes of the integers between 1 and 10. Additionally, implement error handling to handle any potential errors that may occur during the execution of the program."
},
{
"role": "system",
"content": "Here is an example of how y... |
[
{
"role": "user",
"content": "Create an angle converter function which converts degrees to radians. The function should have a time complexity of O(1) and a space complexity of O(1)."
},
{
"role": "system",
"content": "Here's an example of an angle converter function that converts degrees to rad... |
[
{
"role": "user",
"content": "Write a function to calculate the median of an array of integers. The median is the middle value of a sorted array. If the array has an odd number of elements, the median is the middle element. If the array has an even number of elements, the median is the average of the two mi... |
[
{
"role": "user",
"content": "How to remove the last two characters of a string in Python?\nword = \"Hello\""
},
{
"role": "system",
"content": "You can remove the last two characters of a string in Python by using string slicing. Here's an example:\n\n```python\nword = \"Hello\"\nnew_word = wor... |
[
{
"role": "user",
"content": "How to convert a binary string to an integer number without using any built-in functions or libraries?\nbinaryNum = \"1101\""
},
{
"role": "system",
"content": "To convert a binary string to an integer number without using any built-in functions or libraries, you ca... |
[
{
"role": "user",
"content": "How to decode a Base64 string to its corresponding string representation in Python, without using the base64 library?\nbase64_string = \"SGVsbG8gV29ybGQ=\""
},
{
"role": "system",
"content": "To decode a Base64 string without using the base64 library in Python, you ... |
[
{
"role": "user",
"content": "Extract the domain names from the given list of URLs while ignoring subdomains. Each domain name should consist of at least two parts separated by a dot. The output should be sorted in alphabetical order. The input list of URLs will not exceed 1000. \nurl_list = [ \"www.abcd.co... |
[
{
"role": "user",
"content": "Given a list of integers and a target sum, write a function that returns a pair of said integers that add up to the target sum. The pair of integers must also be unique, meaning that if there are multiple pairs that satisfy the condition, the function should return the pair wit... |
[
{
"role": "user",
"content": "Write a Python function to analyze the performance of different sorting algorithms. The function should take in a list of integers and return a dictionary containing the number of comparisons and swaps made by each sorting algorithm. The list will have a minimum length of 10 an... |
[
{
"role": "user",
"content": "Create a class in Python that can be used to store the details of a student. The class should have the following attributes: name, age, grade level, and a list of subjects. \n\nThe class should also have the following methods:\n1. `add_subject(subject)`: This method should take... |
[
{
"role": "user",
"content": "Compute the factorial of the positive integer 7 using recursion, ensuring that the input number is less than or equal to 10."
},
{
"role": "system",
"content": "To compute the factorial of a positive integer using recursion, we can define a function that calls itsel... |
[
{
"role": "user",
"content": "How would you merge two sorted linked lists into one, using recursion?"
},
{
"role": "system",
"content": "To merge two sorted linked lists using recursion, you can follow the steps below:\n\n1. Check if either of the linked lists is empty. If one of them is empty, ... |
[
{
"role": "user",
"content": "Given a binary tree, find the height of the tree and return the maximum sum of values of nodes at any level in the tree."
},
{
"role": "system",
"content": "To find the height of a binary tree, we can recursively calculate the height of the left and right subtrees a... |
[
{
"role": "user",
"content": "Implement a function to reverse a singly linked list in-place. The function should have a time complexity of O(n) and should not use any additional data structures."
},
{
"role": "system",
"content": "To reverse a singly linked list in-place, we can use the followin... |
[
{
"role": "user",
"content": "Write a function that returns 'true' if the number is a prime number, and 'false' otherwise."
},
{
"role": "system",
"content": "Here's an example of a function in Python that checks if a number is prime or not:\n\n```python\ndef is_prime(n):\n # Check if the num... |
[
{
"role": "user",
"content": "Construct a Python class to save details of a student, including their name, age, and grades in three subjects (math, science, and English). \n\nThe class should have the following methods:\n\n1. `__init__(self, name: str, age: int)` - This method initializes the student object... |
[
{
"role": "user",
"content": "Create two classes, \"Animal\" and \"Dog\", in which the \"Dog\" class inherits from the \"Animal\" class.\n\nThe \"Animal\" class should have the following attributes:\n- \"name\" (a string representing the name of the animal)\n- \"age\" (an integer representing the age of the... |
[
{
"role": "user",
"content": "Iterate through the given array and print the prime numbers."
},
{
"role": "system",
"content": "To iterate through an array and print the prime numbers, you can follow these steps:\n\n1. Define a function `is_prime(n)` that checks if a number `n` is prime or not. A... |
[
{
"role": "user",
"content": "Create a SQLite database named \"mydb\" with two tables \"employees\" and \"departments\". \n\nThe \"employees\" table should have the following columns:\n- id (integer, primary key)\n- name (text)\n- age (integer)\n- department_id (integer, foreign key referencing the \"id\" c... |
[
{
"role": "user",
"content": "Implement a priority queue with the following methods:\n\n1. `insert(element, priority)`: Inserts an element into the priority queue with the given priority.\n2. `delete_min()`: Removes and returns the element with the minimum priority from the priority queue. If multiple eleme... |
[
{
"role": "user",
"content": "Use a regular expression to find all the capital letters in the provided string, and count how many times each capital letter appears. Return a dictionary where the keys are the capital letters and the values are the corresponding counts.\n\ntext = \"This is a string with multi... |
[
{
"role": "user",
"content": "How would you write a function to find the mode in an array of numbers, considering the possibility of multiple modes in the array?\nnums = [2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 9, 10, 10]"
},
{
"role": "system",
"content": "One way to write a function to find the mode in ... |
[
{
"role": "user",
"content": "Create a method to compute the sum of squares of all the even numbers from 0 up to n.\nn = 4\n\n#Explanation#\nIn the given test, we only need to compute the sum of squares of numbers from 0 up to n, which involves only one logical step. By rewriting the test, we need to comput... |
[
{
"role": "user",
"content": "How would you write a function to find the highest frequency character in a string, considering both uppercase and lowercase letters? \n\nstring = \"Hello world!\""
},
{
"role": "system",
"content": "Here is an example of a function that finds the highest frequency ... |
[
{
"role": "user",
"content": "Help complete the implementation of the following function\ndef true_false_sum(x: List[Union[bool, int]]) -> Tuple[int, int]:\n true_sum: int = 0\n false_sum: int = 0\n for i in range(len(x)):\n if isinstance(x[i], bool) and x[i] is True:\n true_sum +... |
[
{
"role": "user",
"content": "Generate a python class for calculating prime numbers up to n, where n is an input parameter.\n\nRequirements:\n- The class should have a method named `calculate_primes` that takes an integer `n` as input.\n- The method should return a list of prime numbers up to `n`.\n- The cl... |
[
{
"role": "user",
"content": "Implement a quicksort algorithm in your preferred programming language. Explain the steps involved in the algorithm and analyze its time complexity. Provide a detailed explanation of the partitioning process used in the quicksort algorithm and discuss any possible optimizations... |
[
{
"role": "user",
"content": "Write a program that parses the following JSON structure and stores each element into a variable. Additionally, calculate the total cost by multiplying the quantity of each item by its respective cost and display the result.\n{\n \"items\": [\"apple\", \"orange\", \"banana\"],... |
[
{
"role": "user",
"content": "Create a class in python to store a collection of words and their frequency count, with the following additional requirements:\n\n1. Implement a method to find the most frequent word(s) in the collection. This method should return the word(s) with the highest frequency count.\n... |
[
{
"role": "user",
"content": "List all the different types of sorting algorithms and provide a brief explanation of each algorithm. Additionally, write a function in your preferred programming language to implement one of the sorting algorithms mentioned and test it with a sample input."
},
{
"role"... |
[
{
"role": "user",
"content": "How would you create a for-loop in Python to iterate through all the prime numbers from 1 to 100?"
},
{
"role": "system",
"content": "Here's an example of how you can create a for-loop in Python to iterate through all the prime numbers from 1 to 100:\n\n```python\nf... |
[
{
"role": "user",
"content": "Implement a function called `func_name` that takes an integer `val1` as input and returns a list of integers. The function should generate a list of `val1` length, where each element is a random integer between 1 and 100."
},
{
"role": "system",
"content": "Here's t... |
[
{
"role": "user",
"content": "Construct a program to find the index of a given element in a sorted array with binary search. However, the array contains duplicate elements, and the program should return the index of the first occurrence of the target element.\nlist = [-1, 0, 2, 3, 3, 3, 9, 10]\ntarget = 3"
... |
[
{
"role": "user",
"content": "Generate a balanced ternary search tree data structure in Python."
},
{
"role": "system",
"content": "Sure! Here's an implementation of a balanced ternary search tree in Python:\n\n```python\nclass Node:\n def __init__(self, value):\n self.value = value\n ... |
[
{
"role": "user",
"content": "Use RegEx to identify words in a string and count the occurrences of each word.\nString: \"I have 2 apples and 3 bananas. Apples are delicious, and so are bananas!\""
},
{
"role": "system",
"content": "Here is an example of how you can use RegEx in Python to identif... |
[
{
"role": "user",
"content": "Compute the length of a string without using the built-in length function.\nString: Hello World"
},
{
"role": "system",
"content": "One way to compute the length of a string without using the built-in length function is by iterating through each character of the str... |
[
{
"role": "user",
"content": "Write a class with a method named 'helloWorld' that takes in a string parameter and returns the string with all vowels replaced by the corresponding vowel's next letter in the alphabet."
},
{
"role": "system",
"content": "Here is an example of a Python class with a ... |
[
{
"role": "user",
"content": "Transform the following multidimensional array into a string of comma-separated values in Python.\n[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"
},
{
"role": "system",
"content": "You can use a combination of list comprehension and the `join()` function to transform the multid... |
[
{
"role": "user",
"content": "How can we sort an array of numbers in ascending order in Python using bubble sort algorithm?"
},
{
"role": "system",
"content": "To sort an array of numbers in ascending order using the bubble sort algorithm in Python, you can follow these steps:\n\n1. Define a fun... |
[
{
"role": "user",
"content": "Suggest an enhancement to the following code to support unicode strings. Additionally, the function should ignore any characters that are not part of the ASCII character set and only replace the specified characters in the string."
},
{
"role": "system",
"content": ... |
[
{
"role": "user",
"content": "Write a function that takes two strings and compare to see if they have the same set of characters. The function should also account for case sensitivity and ignore any spaces in the strings.\n\nstring1 = \"Listen\"\nstring2 = \"Silent\"\n\nExample:\nInput:\nstring1 = \"Listen\... |
[
{
"role": "user",
"content": "For each tuple in a given list, write a function to get the first element. The function should only return the first element if it is an odd number. If the first element is even, the function should return the second element. The input list will always contain tuples with two i... |
[
{
"role": "user",
"content": "Write a function to compute the maximum depth of a binary tree from a given list of numbers. However, the list may contain invalid inputs such as strings or negative integers. You need to handle these cases and return an appropriate error message. \n\nFor example:\nnums = [3,9,... |
[
{
"role": "user",
"content": "Find the nth Fibonacci number in a given range, where the range is defined as the Fibonacci sequence between two given numbers.\n\nFor example, given the range [10, 100], the Fibonacci sequence between 10 and 100 is [13, 21, 34, 55, 89]. The nth Fibonacci number in this range w... |
[
{
"role": "user",
"content": "Given a list of valid times in 24-hour format, return the duration in seconds between two times. The times will be provided in the format \"HH:MM:SS\", where HH represents hours (00-23), MM represents minutes (00-59), and SS represents seconds (00-59). The input list will alway... |
[
{
"role": "user",
"content": "Write a function that creates a new array of a given size by copying the elements of a given array. The new array should only contain unique elements from the original array.\ninput_list = [1, 2, 3, 2, 4, 5, 1]\nsize = 4"
},
{
"role": "system",
"content": "Here's th... |
[
{
"role": "user",
"content": "Develop a program to identify the highest number in a given array, without using any built-in functions or sorting algorithms.\nArray: [2, 5, 15, 4, 7, 10]\n\nOR\n\nDevelop a program to identify the highest number in a given array, but you are only allowed to loop through the a... |
[
{
"role": "user",
"content": "Create a function that takes a string representation of a JSON object and converts it into a Python dictionary. The JSON object may contain nested objects, arrays, and primitive data types such as strings, numbers, booleans, and null. The function should handle cases where the ... |
[
{
"role": "user",
"content": "Construct a loop that will print the upside down triangle shape below.\n1\n12\n123\n1234\n12345"
},
{
"role": "system",
"content": "Here is an example of a loop that will print the upside down triangle shape:\n\n```python\nrows = 5\n\nfor i in range(rows, 0, -1):\n ... |
[
{
"role": "user",
"content": "Write a function to sort a dictionary of dictionaries in descending order based on a given key. However, the key can be nested within multiple levels of dictionaries and lists.\n\nFor example:\nd = {'dict1': {'name':'tom','age':20},\n 'dict2': {'name':'jerry','age':25},\n ... |
[
{
"role": "user",
"content": "Implement a function that will take a parameter input and return the number of unique characters in the parameter."
},
{
"role": "system",
"content": "Here is an implementation of the requested function in Python:\n\n```python\ndef count_unique_characters(input_stri... |
[
{
"role": "user",
"content": "Write a function to search in a 1D array of integers, and return the index of the target if it is present. The target must be found using a binary search algorithm.\narr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\ntarget = 8"
},
{
"role": "system",
"content": "Here is the fu... |
[
{
"role": "user",
"content": "Write a function to return the count of all prime numbers from 1 to n (inclusive) where n is a positive integer greater than or equal to 2."
},
{
"role": "system",
"content": "To solve this problem, we can use the Sieve of Eratosthenes algorithm. This algorithm help... |
[
{
"role": "user",
"content": "Implement the Shell sort algorithm in Python.\n\nNote: You are not allowed to use any built-in sorting functions or libraries for this implementation."
},
{
"role": "system",
"content": "Sure! Here's an implementation of the Shell sort algorithm in Python:\n\n```pyt... |
[
{
"role": "user",
"content": "Suggest a way of converting the given JSON object into CSV format, while also ensuring that the output CSV file is sorted in ascending order based on the \"Age\" field."
},
{
"role": "system",
"content": "To convert the given JSON object into CSV format and sort it ... |
[
{
"role": "user",
"content": "Write a function to convert a given integer number to Roman numerals. \nHowever, you are not allowed to use any built-in functions or libraries to convert the number to Roman numerals. You must implement the conversion logic yourself.\n\n#Erroneous Code Reference#\nHere is a pi... |
[
{
"role": "user",
"content": "Using python, limit the number of characters printed in the following statement to only 5 and do not use any built-in string manipulation functions:\nstatement = \"Hello, World!\""
},
{
"role": "system",
"content": "You can limit the number of characters printed in ... |
[
{
"role": "user",
"content": "Define a class for a student with the following additional constraints:\n- The student's name should be at least 5 characters long and can contain only alphabets.\n- The student's age should be between 15 and 25.\n- The student's grade should be a floating-point number between ... |
[
{
"role": "user",
"content": "Construct a for loop that prints the square of each number from 1 to 10 and also prints an asterisk after each square. Additionally, the program should skip any number that is divisible by 3 and only print the squares and asterisks for the remaining numbers."
},
{
"role... |
[
{
"role": "user",
"content": "Create a list in Python called \"my_list\" and populate it with five prime numbers ranging from 1 to "
},
{
"role": "system",
"content": "To create a list in Python called \"my_list\" and populate it with five prime numbers ranging from 1 to 10, you can use the foll... |
[
{
"role": "user",
"content": "Compare two strings and remove all letters from the first string which are present in the second string and vice versa, while also keeping track of the frequency of each letter that is removed. Finally, return the letters that were removed along with their frequencies in a sort... |
[
{
"role": "user",
"content": "Write a function that takes in two lists of numbers as input. The first list represents the coefficients of a polynomial equation, while the second list represents the values to be substituted into the equation. The function should return a new list that contains the results of... |
[
{
"role": "user",
"content": "Given a positive integer 'base' and a positive integer 'exponent', write a function to calculate the result of 'base' raised to the power of 'exponent'. The function should handle large values of 'exponent' efficiently.\nbase: 10 \nexponent: 1000000"
},
{
"role": "syste... |
[
{
"role": "user",
"content": "Construct an algorithm for reversing a string without using any built-in string reversal functions or methods. The algorithm should have a time complexity of O(n), where n is the length of the string, and a space complexity of O(1)."
},
{
"role": "system",
"content"... |
[
{
"role": "user",
"content": "Compare two arrays and output the result in Boolean. However, instead of comparing the arrays directly, you need to compare the arrays while ignoring any duplicate elements and taking into account the order of the remaining elements. Additionally, the comparison should only con... |
[
{
"role": "user",
"content": "Create a data structure for a streaming interface that holds a maximum of 5 numbers. Implement the following additional methods: \n1. A method to return the sum of all the numbers in the data structure.\n2. A method to return the average of all the numbers in the data structure... |
[
{
"role": "user",
"content": "Develop a DFS algorithm in Python that can find all possible paths from a starting node to a target node in a directed graph."
},
{
"role": "system",
"content": "Here's a Python implementation of the Depth First Search (DFS) algorithm that finds all possible paths f... |
[
{
"role": "user",
"content": "Create a python function that takes a single integer as an argument and prints out the corresponding multiplication table. However, the function should only display the odd numbers in the table, skipping any even numbers. Additionally, the function should handle cases where the... |
[
{
"role": "user",
"content": "Calculate the factorial of 8 using a recursive function and ensure that the function is implemented in a separate module."
},
{
"role": "system",
"content": "To calculate the factorial of a number using a recursive function in a separate module, follow these steps:\... |
[
{
"role": "user",
"content": "In Python, you have a set called `my_set` containing the elements `1, 2, 3, 4, 5`. How do you retrieve the 3rd element of `my_set`?"
},
{
"role": "system",
"content": "In Python, you cannot directly retrieve the nth element from a set as sets are unordered collectio... |
[
{
"role": "user",
"content": "Segregate a given array of numbers into even and odd. The even numbers should be placed at the beginning of the array and the odd numbers should be placed at the end of the array. Additionally, the order of the numbers within the even and odd sections should be maintained. [1, ... |
[
{
"role": "user",
"content": "Convert the given hexadecimal color code to RGB format, without using any built-in functions or libraries. The input will always be a valid hexadecimal color code. The output should be a string in the format \"RGB(x, y, z)\" where x, y, and z are integers representing the red, ... |
[
{
"role": "user",
"content": "In the following code, modify the function to take a list of integers as an argument. The function should convert each integer to its corresponding binary representation and return a list of strings containing the binary representations.\n\ndef convert_to_binary(input_list):\n ... |
[
{
"role": "user",
"content": "Write a function to transform a dataset into a matrix, where rows represent data points followed by their labels. The dataset consists of tuples, where each tuple represents a data point and contains three elements. The first two elements represent the features of the data poin... |
[
{
"role": "user",
"content": "Generate an array containing the next n numbers in the Fibonacci sequence, but exclude any numbers that are divisible by 3."
},
{
"role": "system",
"content": "Here is a Python code snippet that generates an array containing the next n numbers in the Fibonacci seque... |
[
{
"role": "user",
"content": "Write a function to create a random sequence of 0s and 1s, where the number of 0s and 1s are approximately equal."
},
{
"role": "system",
"content": "Here's an example of a function in Python that creates a random sequence of 0s and 1s, where the number of 0s and 1s... |
[
{
"role": "user",
"content": "Create a function to sort a list of dictionaries alphabetically in Python based on a specific key in each dictionary."
},
{
"role": "system",
"content": "Here's an example function that sorts a list of dictionaries alphabetically based on a specific key:\n\n```pytho... |
[
{
"role": "user",
"content": "Suggest an appropriate algorithm to filter out unwanted words from a given paragraph of text, but with the additional requirement of ignoring case sensitivity while filtering."
},
{
"role": "system",
"content": "One suitable algorithm to filter out unwanted words fr... |
[
{
"role": "user",
"content": "Create a code to calculate the most frequent character in a given string, but exclude any punctuation characters and consider only alphabetic characters.\ns = \"Hello, world!\""
},
{
"role": "system",
"content": "You can use the following code to calculate the most ... |
[
{
"role": "user",
"content": "Create a program that capitalizes the first letter of every word in a sentence, excluding any conjunctions such as \"and\" or \"but\"."
},
{
"role": "system",
"content": "Here is a Python program that capitalizes the first letter of every word in a sentence, excludi... |
[
{
"role": "user",
"content": "Given a text string, generate a Python code snippet to find the number of occurrences of a given word. However, the code snippet should exclude any occurrences of the word that are inside a quoted string.\n\nFor example, if the given text string is:\n\"The quick brown fox jumpe... |
[
{
"role": "user",
"content": "Given an array of integers, write a function to check if the sum of any two of them equals the given parameter ‘n’. The function should also return the indices of the two numbers whose sum equals ‘n’. Additionally, the function should have a time complexity of O(n) and should n... |
[
{
"role": "user",
"content": "Using the provided input, calculate the SHA384 checksum in Python.\nstring = \"Hello World!\""
},
{
"role": "system",
"content": "To calculate the SHA384 checksum in Python, you can use the `hashlib` library. Here's an example code snippet that calculates the SHA384... |
[
{
"role": "user",
"content": "Split a string into its individual words and store it in a list, but exclude any words that start with a vowel.\nstring = \"Hello world, this is a test string.\""
},
{
"role": "system",
"content": "Here's a possible solution using list comprehension in Python:\n\n``... |
[
{
"role": "user",
"content": "Create a class called Cat to represent a type of pet. The Cat class should have the following attributes and methods:\n\nAttributes:\n- name: a string that represents the name of the cat\n- age: an integer that represents the age of the cat\n- breed: a string that represents th... |
[
{
"role": "user",
"content": "In Python, define a class for a rectangle object with the following attributes and methods:\n\nAttributes:\n- length (a positive integer)\n- width (a positive integer)\n\nMethods:\n- get_area: returns the area of the rectangle (length * width)\n- get_perimeter: returns the peri... |
[
{
"role": "user",
"content": "Edit the following code snippet to output the sum of the first five Fibonacci numbers instead of \"four\"."
},
{
"role": "system",
"content": "```python\ndef fibonacci(n):\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n else:\n retu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.