source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
code_exercise_27k
4,416
Write a Python function to remove duplicates from a list of strings by keeping only the first occurrence of each string. The function should return a list of unique strings in the order they first appeared in the input list. The code should start with: ```python from typing import List def remove_duplicates_from_list...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_from_list(strings: List[str]) -> List[str]: """ Remove duplicates from a list of strings by keeping only the first occurrence of each string. Args: strings (List[str]):...
code_exercise_27k
4,424
Write a Python function to find the nth largest element in a given list of integers using the quickselect algorithm. The function should be efficient and handle edge cases such as an empty list or invalid n values. The code should start with: ```python from typing import List def find_nth_largest(arr: List[int], n: i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_nth_largest(arr: List[int], n: int) -> int: """ Find the nth largest element in a given list of integers using the quickselect algorithm. Args: arr (List[int]): The list of integers...
code_exercise_27k
4,434
Write a Python function to find the longest palindromic substring in a given string. The function should efficiently handle the problem using a dynamic programming approach. The code should start with: ```python def longest_palindromic_substring(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def longest_palindromic_substring(s: str) -> str: """ Find the longest palindromic substring in a given string using dynamic programming. Args: s (str): The input string. Returns: str: The longest palin...
code_exercise_27k
4,443
Write a Python function to find the common elements among a list of sets. The function should take a list of sets as input and return a set containing the common elements across all the sets in the list. If the list of sets is empty, the function should return an empty set. The code should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Set def find_common_elements(sets: List[Set[int]]) -> Set[int]: """ Finds the common elements among a list of sets. Args: sets (List[Set[int]]): A list of sets containing integers. Ret...
code_exercise_27k
4,445
Write a Python function that accepts an integer as a parameter and returns the sum of its digits. If the input is not an integer, raise a `TypeError`. The function should handle both positive and negative integers. The code should start with: ```python def sum_of_digits(number: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_digits(number: int) -> int: """ Calculate the sum of the digits of a given integer. This function takes an integer as input and returns the sum of its digits. If the input is not an integer, a TypeError is ra...
code_exercise_27k
4,447
Write a Python function to find the largest common prefix of a set of strings, ignoring duplicates. The function should efficiently determine the longest prefix that is common to all strings in the set. The code should start with: ```python from typing import Set def find_largest_common_prefix(strings: Set[str]) -> st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Set def find_largest_common_prefix(strings: Set[str]) -> str: """ Find the largest common prefix of a set of strings, ignoring duplicates. Args: strings (Set[str]): A set of strings from which to...
code_exercise_27k
4,451
Write a Python function to determine if two sets are disjoint by comparing their minimum and maximum values. The function should return `True` if the sets are disjoint, and `False` otherwise. The function should handle empty sets by considering them as disjoint. The code should start with: ```python def are_disjoint_b...
Here is the Python code to solve the given problem in the markdown block: ```python def are_disjoint_by_min_max(set_1: set, set_2: set) -> bool: """ Determine if two sets are disjoint by comparing their minimum and maximum values. Args: set_1 (set): The first set. set_2 (set): The second se...
code_exercise_27k
4,452
Write a Python function to find the union of two dictionaries. The union of two dictionaries is a new dictionary that contains all the keys from both dictionaries, with values from the second dictionary overriding those from the first dictionary if there are duplicate keys. The function should handle any type of dictio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def find_union(dict1: Dict[Any, Any], dict2: Dict[Any, Any]) -> Dict[Any, Any]: """ Find the union of two dictionaries. Args: dict1 (Dict[Any, Any]): The first dictionary. dict2...
code_exercise_27k
4,458
Write a Python function to count the number of occurrences of each key in a dictionary of lists. The function should return a dictionary where the keys are the elements from the lists in the input dictionary, and the values are the counts of their occurrences across all lists. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def count_occurrences(dictionary: Dict[str, List[int]]) -> Dict[int, int]: """ Count the number of occurrences of each key in a dictionary of lists. Args: dictionary (Dict[str, List[in...
code_exercise_27k
4,463
Write a Python function to find the second highest value in a given dictionary. The function should handle dictionaries with unique and non-unique values, and it should raise a `ValueError` if the dictionary is empty or contains less than two values. The code should start with: ```python from typing import Dict def f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def find_second_highest_value(dictionary: Dict[str, int]) -> int: """ Find the second highest value in a given dictionary. Args: dictionary (Dict[str, int]): The input dictionary with string...
code_exercise_27k
4,465
Write a Python function to filter out `None` values from a given list of elements. The function should return a new list containing only the elements that are not `None`. The code should start with: ```python from typing import List, Any def filter_none_values(elements: List[Any]) -> List[Any]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def filter_none_values(elements: List[Any]) -> List[Any]: """ Filters out None values from the given list of elements. Args: elements (List[Any]): The list of elements to filter. R...
code_exercise_27k
4,467
Write a Python function to find all key-value pairs in a given dictionary that have the highest value. If multiple keys have the same highest value, the function should return all such key-value pairs. The function should handle an empty dictionary by raising a `ValueError`. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def find_highest_value_pairs(dictionary: Dict[str, int]) -> List[Tuple[str, int]]: """ Finds all key-value pairs in a dictionary that have the highest value. Args: dictionary (D...
code_exercise_27k
4,468
Write a Python function to find the common elements among multiple sets. The function should take a list of sets as input and return a set containing the common elements found in all the input sets. The code should start with: ```python from typing import List def find_common_elements(sets: List[set]) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(sets: List[set]) -> set: """ Find the common elements among multiple sets. Args: sets (List[set]): A list of sets to find the common elements from. Returns: ...
code_exercise_27k
4,471
Write a Python function to find the intersection of two lists, considering elements with a specific length and data type. The function should return a new list containing the elements that satisfy the length and data type criteria. The function should raise a `ValueError` if either the `length` or `data_type` is not sp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Type def find_intersection(list_1: List, list_2: List, length: int, data_type: Type) -> List: """ Finds the intersection of two lists based on the specified length and data type. Args: list...
code_exercise_27k
4,472
Write a Python function to check if a variable is not `None`. The function should return `True` if the variable is not `None`, and `False` otherwise. The function should handle any type of variable, including integers, strings, lists, dictionaries, and custom objects. The code should start with: ```python def is_not_no...
Here is the Python code to solve the given problem in the markdown block: ```python def is_not_none(var) -> bool: """ Check if a variable is not None. Args: var: The variable to check. Returns: bool: True if the variable is not None, False otherwise. """ return var is not None ...
code_exercise_27k
4,475
Write a Python function that checks if any value in a given list of integers is divisible by 5. If at least one value is divisible by 5, the function should return `True`. Otherwise, it should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with negative numbers. T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def check_divisible_by_5(numbers: List[int]) -> Optional[bool]: """ Check if any value in the list of integers is divisible by 5. Args: numbers (List[int]): A list of integers to c...
code_exercise_27k
4,478
Write a Python function to check if a variable is `None`, an empty string, an empty list, an empty tuple, an empty dictionary, or an empty set. The function should return `True` if the variable is any of these empty or `None` types, and `False` otherwise. The code should start with: ```python def is_none_or_empty(varia...
Here is the Python code to solve the given problem in the markdown block: ```python def is_none_or_empty(variable) -> bool: """ Checks if a variable is None or empty. Args: variable: The variable to be checked. Returns: bool: True if the variable is None, an empty string, an empty list...
code_exercise_27k
4,479
Write a Python function to find the difference in values between two dictionaries. The function should return a new dictionary where each key is a key present in either or both dictionaries, and the value is the difference between the values of that key in the two dictionaries. If a key is present in only one dictionar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def find_difference(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]: """ Calculate the difference in values between two dictionaries. Args: dict1 (Dict[str, int]): The first ...
code_exercise_27k
4,483
Write a Python function to find the intersection of two dictionaries based on keys and values. The function should return a new dictionary containing only the key-value pairs that are present in both input dictionaries with the same keys and values. The code should start with: ```python from typing import Dict def fi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def find_intersection_by_key_value(dict1: Dict, dict2: Dict) -> Dict: """ Find the intersection of two dictionaries based on both keys and values. This function takes two dictionaries as input and r...
code_exercise_27k
4,486
Write a Python function that processes a list of strings by converting each string to its uppercase form. If the list is empty, the function should return `None`. Otherwise, it should return the processed list of uppercase strings. The code should start with: ```python from typing import List, Optional def process_st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def process_string_list(string_list: List[str]) -> Optional[List[str]]: """ Process a list of strings by converting each string to its uppercase form. Args: string_list (List[str])...
code_exercise_27k
4,487
Write a Python function to find the intersection of two lists, considering only prime numbers less than a specified maximum value. The function should return a list of prime numbers that are present in both input lists and are less than the specified maximum value. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def prime_intersection(list1: List[int], list2: List[int], max_value: int) -> List[int]: """ Finds the intersection of two lists, considering only prime numbers less than a specified value. Args: ...
code_exercise_27k
4,488
Write a Python function to check if a dictionary is a subset of another dictionary. The function should return `True` if every key-value pair in the first dictionary (subset) exists in the second dictionary (superset), and `False` otherwise. The function should handle dictionaries with any types of keys and values. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def is_subset(subset_dict: Dict[Any, Any], superset_dict: Dict[Any, Any]) -> bool: """ Check if a dictionary is a subset of another dictionary. Args: subset_dict (Dict[Any, Any]): The d...
code_exercise_27k
4,490
Write a Python function to check if a list contains only `None` values. The function should return `True` if all elements in the list are `None`, and `False` otherwise. The function should handle lists of any length, including empty lists. The code should start with: ```python from typing import List def is_list_none...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_list_none(lst: List[None]) -> bool: """ Check if a list contains only None values. Args: lst (List[None]): The list to be checked. Returns: bool: True if the list contain...
code_exercise_27k
4,491
Write a Python function to compute the union of two lists, ensuring that the result contains unique elements and is sorted in ascending order. The function should return the union as a list. The code should start with: ```python from typing import List def compute_union_of_lists(list1: List[int], list2: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_union_of_lists(list1: List[int], list2: List[int]) -> List[int]: """ Compute the union of two lists, ensuring the result contains unique elements and is sorted in ascending order. Args: ...
code_exercise_27k
4,493
Write a Python function to remove all occurrences of a specific element from a given set. The function should return a new set with the specified element removed. If the element is not present in the original set, the function should return the original set itself. The code should start with: ```python def remove_eleme...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_element_from_set(s: set, element) -> set: """ Removes all occurrences of a specific element from a given set. Args: s (set): The original set from which the element needs to be removed. element (a...
code_exercise_27k
4,495
Write a Python function to find the union of two lists, removing duplicates, and ensuring the resulting list is sorted in ascending order. The function should handle lists of integers and return a new list containing all unique elements from both lists, sorted in ascending order. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union_sorted(list1: List[int], list2: List[int]) -> List[int]: """ Find the union of two lists, removing duplicates, and return the result sorted in ascending order. Args: list1 (Li...
code_exercise_27k
4,497
Write a Python function to check if one set is a subset of another set. The function should return `True` if all elements of the first set are present in the second set, and `False` otherwise. The function should handle sets of any size and type of elements. The code should start with: ```python def is_subset(A: set, ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_subset(A: set, B: set) -> bool: """ Check if set A is a subset of set B. Parameters: A (set): The first set. B (set): The second set. Returns: bool: True if A is a subset of B, False otherwise. "...
code_exercise_27k
4,499
Write a Python function to compute the union of multiple lists. The function should take a list of lists as input and return a set containing all unique elements from all the lists. The code should start with: ```python from typing import List def compute_union(lists: List[List[int]]) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_union(lists: List[List[int]]) -> set: """ Compute the union of multiple lists. Args: lists (List[List[int]]): A list of lists, where each inner list contains integers. Retur...
code_exercise_27k
4,500
Write a Python function to check if all numbers in a given list are positive. If any number is negative, the function should return `None`. If all numbers are positive, the function should return `True`. The function should handle an empty list by returning `True`. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def check_positive_numbers(numbers: List[int]) -> Optional[bool]: """ Checks if all numbers in the given list are positive. Args: numbers (List[int]): A list of integers to be chec...
code_exercise_27k
4,501
Write a Python function to find the intersection of two sets `A` and `B` without using the built-in `intersection` method. The function should iterate through the elements of one set and check if each element is present in the other set. If an element is found in both sets, it should be added to the result set. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python def find_intersection_manual(A: set, B: set) -> set: """ Finds the intersection of two sets A and B without using the built-in intersection method. Args: A (set): The first set. B (set): The second set. ...
code_exercise_27k
4,504
Write a Python function to check if any key in a dictionary has a value of `None`. The function should return `True` if at least one key has a value of `None`, and `False` otherwise. The code should start with: ```python from typing import Dict def has_none_value(dictionary: Dict) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def has_none_value(dictionary: Dict) -> bool: """ Check if any key in a dictionary has a value of None. Args: dictionary (Dict): The dictionary to check. Returns: bool: True if ...
code_exercise_27k
4,506
Write a Python function to check if all dictionaries in a given list contain a specific key. If any dictionary is missing the key, the function should return `None`. If all dictionaries contain the key, the function should return `True`. The function should handle an empty list of dictionaries by returning `None`. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Optional def check_key_presence(dict_list: List[Dict[str, any]], key: str) -> Optional[bool]: """ Check if all dictionaries in a list contain a specific key. Args: dict_list (List[Dic...
code_exercise_27k
4,507
Write a Python function to find the symmetric difference between two sets A and B (i.e., elements present in either A or B but not in both). The function should return a new set containing the symmetric difference. The code should start with: ```python def symmetric_difference(A: set, B: set) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python def symmetric_difference(A: set, B: set) -> set: """ Finds the symmetric difference between two sets A and B. The symmetric difference is the set of elements that are in either A or B but not in both. Args: A (...
code_exercise_27k
4,508
Write a Python function to compute the union of two lists while preserving the original order of elements from both lists. The function should ensure that each element appears only once in the resulting list, regardless of its occurrence in the input lists. The code should start with: ```python from typing import List ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def union_of_lists(list1: List[int], list2: List[int]) -> List[int]: """ Compute the union of two lists, preserving the original order of elements. Args: list1 (List[int]): The first input l...
code_exercise_27k
4,510
Write a Python function to check if a list of lists contains any `None` values. The function should return `True` if there is at least one `None` value in any of the sublists, and `False` otherwise. The code should start with: ```python from typing import List def contains_none(lst: List[List[any]]) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def contains_none(lst: List[List[any]]) -> bool: """ Check if a list of lists contains any None values. Args: lst (List[List[any]]): The list of lists to be checked. Returns: bo...
code_exercise_27k
4,511
Write a Python function to return the dictionary keys sorted by their values in descending order. If two keys have the same value, their order should be preserved based on their original order in the dictionary. The code should start with: ```python from typing import Dict, List def sort_dictionary_keys_by_values_des...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def sort_dictionary_keys_by_values_desc(dictionary: Dict[str, int]) -> List[str]: """ Sorts the keys of a dictionary based on their corresponding values in descending order. Args: ...
code_exercise_27k
4,512
Write a Python function to create a new set that contains all the elements of a given set multiplied by a specified factor. The function should handle both positive and negative integers in the input set. The code should start with: ```python def multiply_set_elements(A: set, factor: int) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_set_elements(A: set, factor: int) -> set: """ Create a new set that contains all the elements of set A multiplied by the specified factor. Args: A (set): The input set containing integers. facto...
code_exercise_27k
4,513
Write a Python function to find the union of two lists, preserving the original order of elements and removing duplicates. The function should take two lists as input and return a new list that includes all unique elements from both input lists, while preserving the original order of elements. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union(list1: List, list2: List) -> List: """ Finds the union of two lists, preserving the original order of elements and removing duplicates. Args: list1 (List): The first list. ...
code_exercise_27k
4,518
Write a Python function to check if any string in a given list of strings has a length greater than a specified maximum length. If any string exceeds this length, the function should return `None`. Otherwise, it should return `False`. The function should also handle cases where the input list is empty. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def check_string_lengths(strings: List[str], max_length: int) -> Optional[bool]: """ Check if any string in the list has a length greater than the specified maximum length. Args: s...
code_exercise_27k
4,519
Write a Python function to determine if a given set `A` is a proper subset of another set `B`. A proper subset is defined as a set where all elements of `A` are also in `B`, but `B` contains at least one additional element that is not in `A`. The function should start with: ```python def is_proper_subset(A: set, B: se...
Here is the Python code to solve the given problem in the markdown block: ```python def is_proper_subset(A: set, B: set) -> bool: """ Determines if set A is a proper subset of set B. A proper subset is defined as a set where all elements of A are also in B, but B contains at least one additional elemen...
code_exercise_27k
4,522
Write a Python function to compute the union of two lists, ensuring that the resulting list contains only unique elements and is sorted in ascending order. The function should handle lists of integers and return a new list containing the union of the two input lists. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_union_sorted(list1: List[int], list2: List[int]) -> List[int]: """ Computes the union of two lists, ensuring the result contains only unique elements and is sorted in ascending order. Ar...
code_exercise_27k
4,523
Write a Python function to count the number of times an element appears in a given set. Since sets in Python do not allow duplicate elements, the function should return 1 if the element is present in the set, and 0 if it is not. The function should handle any hashable element type. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def count_element_occurrences(s: set, element) -> int: """ Counts the number of times an element appears in a set. Since sets do not allow duplicate elements, the function returns 1 if the element is present in the set, ...
code_exercise_27k
4,525
Write a Python function to get a list of the largest n values from a given dictionary, sorted in increasing order. The function should handle cases where n is greater than the number of values in the dictionary by returning all values sorted in increasing order. The function should also handle cases where n is less tha...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def get_largest_values(dictionary: Dict[any, int], n: int) -> List[int]: """ Returns a list of the largest n values from the given dictionary, sorted in increasing order. Args: diction...
code_exercise_27k
4,526
Write a Python function to find the union of two lists, ensuring that the result is sorted in ascending order and duplicates are removed. The function should use the set data structure to handle duplicates and the sorted function to sort the result. The code should start with: ```python from typing import List def sor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sorted_union(list1: List[int], list2: List[int]) -> List[int]: """ Returns the union of two lists, sorted in ascending order and with duplicates removed. Args: list1 (List[int]): The fir...
code_exercise_27k
4,529
Write a Python function to combine the values in a dictionary of lists into a dictionary of sets. Each key in the input dictionary should map to a list of values, and the function should return a new dictionary where each key maps to a set of unique values from the corresponding list. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Set def combine_lists_to_sets(dictionary: Dict[str, List[int]]) -> Dict[str, Set[int]]: """ Combines the values in a dictionary of lists into a dictionary of sets. Args: dictionary (D...
code_exercise_27k
4,531
Write a Python function to check if two sets are disjoint, meaning they have no common elements. The function should return `True` if the sets are disjoint and `False` otherwise. The code should start with: ```python def are_sets_disjoint(set_a: set, set_b: set) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def are_sets_disjoint(set_a: set, set_b: set) -> bool: """ Checks if two sets, set_a and set_b, are disjoint. Parameters: set_a (set): The first set. set_b (set): The second set. Returns: bool: ...
code_exercise_27k
4,532
Write a Python function to check if a list contains only `None` values or `None` values combined with a specific value. The function should return `True` if the list meets the criteria, and `False` otherwise. The function should handle edge cases such as an empty list and lists with mixed values. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def check_list_for_none_or_value(lst: List[Any], value: Any) -> bool: """ Check if a list contains only None values or None values combined with a specific value. Args: lst (List[Any]):...
code_exercise_27k
4,533
Write a Python function to remove empty lists from a given dictionary. The function should iterate through the dictionary and remove any key-value pairs where the value is an empty list. The function should handle dictionaries with various types of values, including nested dictionaries and lists. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def remove_empty_lists(dictionary: Dict[Any, Any]) -> Dict[Any, Any]: """ Removes empty lists from a dictionary, including nested dictionaries and lists. Args: dictionary (Dict[Any, Any...
code_exercise_27k
4,534
Write a Python function to sort a dictionary of lists based on the lengths of the lists in descending order. If two lists have the same length, they should remain in the order they were originally in the dictionary. The function should return a new dictionary with the sorted lists. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def sort_dictionary_by_list_length_desc(dictionary: Dict[str, List[int]]) -> Dict[str, List[int]]: """ Sorts a dictionary of lists based on their lengths in descending order. Parameters: d...
code_exercise_27k
4,536
Write a Python function to create a new set that contains all possible ordered pairs (a, b) where a is in set A and b is in set B. The function should handle the case where either A or B is not a set by raising a `TypeError`. The code should start with: ```python def create_ordered_pairs_set(A, B): ```
Here is the Python code to solve the given problem in the markdown block: ```python def create_ordered_pairs_set(A, B): """ Creates a new set that contains all possible ordered pairs (a, b) where a is in A and b is in B. Args: A (set): The first set A. B (set): The second set B. Return...
code_exercise_27k
4,537
Write a Python function that checks if all numbers in a given list are divisible by a specific divisor. If all numbers are divisible, the function should return `None`. If at least one number is not divisible, the function should return the index of the first non-divisible number. The function should also handle input ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def check_divisibility(numbers: List[int], divisor: int) -> Optional[int]: """ Check if all numbers in a list are divisible by a specific divisor. Args: numbers (List[int]): A list...
code_exercise_27k
4,539
Write a Python function to compute the Cartesian product of two sets `A` and `B`. The Cartesian product of two sets `A` and `B` is the set of all ordered pairs `(a, b)` where `a` is an element of `A` and `b` is an element of `B`. The function should handle sets of any hashable elements and should return the result as a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Set, Tuple def cartesian_product(A: Set, B: Set) -> Set[Tuple]: """ Compute the Cartesian product of two sets A and B. The Cartesian product of two sets A and B is the set of all ordered pairs (a, b) ...
code_exercise_27k
4,540
Write a Python function to compute the union of two lists without using any built-in functions or data structures, except for basic list operations like appending and checking membership. The function should handle lists of any type of elements, including duplicates within the same list. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def compute_union(list1: List[Any], list2: List[Any]) -> List[Any]: """ Compute the union of two lists without using any built-in functions or data structures, except for basic list operations. ...
code_exercise_27k
4,542
Write a Python function to generate the power set of a given set. The power set is the set of all possible subsets, including the empty set and the set itself. The function should return a set of frozensets to ensure immutability and hashability. The code should start with: ```python from typing import Set def genera...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Set def generate_power_set(A: Set[int]) -> Set[frozenset]: """ Generate the power set of a given set A. Parameters: A (Set[int]): The set for which the power set is to be generated. Returns: ...
code_exercise_27k
4,543
Write a Python function to create a dictionary from a given list of keys and a default value. The function should ensure that all keys in the list are unique and handle cases where the list of keys might contain duplicates. If duplicates are found, the function should raise a `ValueError`. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, List def create_dictionary_with_default(keys: List[Any], default_value: Any) -> Dict[Any, Any]: """ Create a dictionary using a given list of unique keys and a default value. Args: key...
code_exercise_27k
4,544
Write a Python function to find the union of two lists, without using any built-in functions or data structures and removing duplicates. The function should start with: ```python def find_union(list1: list, list2: list) -> list: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_union(list1: list, list2: list) -> list: """ Return the union of two lists without using any built-in functions or data structures, and removing duplicates. Args: list1 (list): The first input list. ...
code_exercise_27k
4,546
Write a Python function to check if a given set is a subset of another set. The function should return `True` if all elements of the first set are present in the second set, and `False` otherwise. The function should handle sets of any size, including empty sets. The code should start with: ```python def is_subset(set...
Here is the Python code to solve the given problem in the markdown block: ```python def is_subset(set1: set, set2: set) -> bool: """ Check if set1 is a subset of set2. Parameters: set1 (set): The first set to check. set2 (set): The second set to check against. Returns: bool: True if set1 i...
code_exercise_27k
4,549
Write a Python function to check if a given set is a proper subset of another set. A proper subset is a subset that is not equal to the original set. The function should return `True` if the first set is a proper subset of the second set, and `False` otherwise. The function should also raise a `TypeError` if the inputs...
Here is the Python code to solve the given problem in the markdown block: ```python def is_proper_subset(set1: set, set2: set) -> bool: """ Check if a given set is a proper subset of another set. A proper subset is a subset that is not equal to the original set. Args: set1 (set): The first set...
code_exercise_27k
4,551
Write a Python function to get the first and last key-value pairs from a given dictionary. The function should return a tuple containing these two pairs. If the dictionary is empty, the function should raise a `ValueError`. The code should start with: ```python def get_first_and_last_items(dictionary: dict) -> tuple: ...
Here is the Python code to solve the given problem in the markdown block: ```python def get_first_and_last_items(dictionary: dict) -> tuple: """ Get the first and last key-value pairs from a dictionary. Args: dictionary (dict): The input dictionary. Returns: tuple: A tuple containing t...
code_exercise_27k
4,553
Write a Python function to check if a given set is a superset of another set. The function should handle both mutable and immutable sets (i.e., `set` and `frozenset`). The function should return `True` if the first set is a superset of the second set, and `False` otherwise. The code should start with: ```python def is...
Here is the Python code to solve the given problem in the markdown block: ```python def is_superset(set_a: set, set_b: set) -> bool: """ Check if set_a is a superset of set_b. Parameters: set_a (set or frozenset): The set to check if it is a superset. set_b (set or frozenset): The set to check if i...
code_exercise_27k
4,560
Write a Python function to remove all key-value pairs from a dictionary except for those specified. The function should take a dictionary and a list of keys to keep, and return a new dictionary containing only the specified key-value pairs. The original dictionary should not be modified. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def filter_dictionary(dictionary: Dict, keys_to_keep: List[str]) -> Dict: """ Returns a new dictionary containing only the specified key-value pairs from the input dictionary. Args: di...
code_exercise_27k
4,563
Write a Python function to find the union of two sorted lists, removing duplicates. The function should efficiently merge the two lists while maintaining the sorted order and ensuring that no duplicate elements are present in the resulting list. The code should start with: ```python from typing import List def find_un...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union_of_sorted_lists(sorted_list1: List[int], sorted_list2: List[int]) -> List[int]: """ Returns the union of two sorted lists, removing duplicates. Args: sorted_list1 (List[int]):...
code_exercise_27k
4,564
Write a Python function to find the intersection of two sets. The function should return a new set containing only the elements that are present in both input sets. The code should start with: ```python def intersection_of_sets(set1: set, set2: set) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python def intersection_of_sets(set1: set, set2: set) -> set: """ Find the intersection of two sets. Args: set1 (set): The first input set. set2 (set): The second input set. Returns: set: A new set con...
code_exercise_27k
4,565
Write a Python function to calculate the cumulative sum of values in a dictionary. The function should return a new dictionary where each key-value pair represents the cumulative sum of values up to that key in the original dictionary. The function should handle only numeric values and raise appropriate exceptions for ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_cumulative_sum(dictionary: Dict[str, int]) -> Dict[str, int]: """ Calculates the cumulative sum of values in a dictionary. Args: dictionary (Dict[str, int]): A dictionary conta...
code_exercise_27k
4,569
Write a Python function to find the symmetric difference between two sets. The symmetric difference of two sets is defined as the set of elements which are in either of the sets but not in their intersection. The function should return a new set containing the symmetric difference. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def symmetric_difference(set1: set, set2: set) -> set: """ Compute the symmetric difference between two sets. The symmetric difference of two sets is the set of elements which are in either of the sets but not in their inte...
code_exercise_27k
4,571
Write a Python function to remove the nth item from a given dictionary. The function should take a dictionary and an integer `n` as input and return the dictionary after removing the nth item. If the index `n` is out of range, the function should raise an `IndexError`. The function should also raise a `TypeError` if th...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_nth_item(dictionary: dict, n: int) -> dict: """ Remove the nth item from a given dictionary. Args: dictionary (dict): The dictionary from which to remove the item. n (int): The index of the item t...
code_exercise_27k
4,572
Write a Python function to find the symmetric difference between two sets. The symmetric difference of two sets is the set of elements that are in either of the sets, but not in both. The function should be able to handle sets of any size and type of elements. The code should start with: ```python def symmetric_differe...
Here is the Python code to solve the given problem in the markdown block: ```python def symmetric_difference(set1: set, set2: set) -> set: """ Returns the symmetric difference between two sets. The symmetric difference of two sets is the set of elements that are in either set1 or set2, but not both. A...
code_exercise_27k
4,574
Write a Python function to remove duplicate elements from a given list and return a new list with unique elements while preserving the order of their first occurrence. The function should start with: ```python from typing import List def remove_duplicates_preserve_order(input_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_preserve_order(input_list: List[int]) -> List[int]: """ Removes duplicate elements from a given list while preserving the order of their first occurrence. Args: input_l...
code_exercise_27k
4,578
Write a Python function to create a new dictionary with the same keys as a given dictionary but with values replaced by the corresponding elements from a provided list. The function should raise a `ValueError` if the length of the list of new values does not match the number of keys in the original dictionary. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def create_new_dict_with_different_values(old_dict: Dict[str, int], new_values: List[int]) -> Dict[str, int]: """ Create a new dictionary with the same keys as the given dictionary but with values ...
code_exercise_27k
4,579
Write a Python function to find the maximum and minimum elements in a given set of integers. The function should return a tuple containing the maximum and minimum elements. If the set is empty, the function should raise a `ValueError`. The code should start with: ```python def find_max_min(some_set: set) -> tuple: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def find_max_min(some_set: set) -> tuple: """ Find the maximum and minimum elements in a given set of integers. Args: some_set (set): A set containing integers. Returns: tuple: A tuple containing the ma...
code_exercise_27k
4,581
Write a Python function to find the union of two sorted lists, preserving the original order of elements and removing duplicates. The function should efficiently merge the two lists while maintaining the sorted order and ensuring that each element appears only once in the resulting list. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union_of_sorted_lists(sorted_list1: List[int], sorted_list2: List[int]) -> List[int]: """ Find the union of two sorted lists, preserving the original order of elements and removing duplicates. ...
code_exercise_27k
4,582
Write a Python function to combine values in a dictionary of lists into a dictionary of tuples. Each key in the original dictionary should map to a tuple containing the elements of the corresponding list. The function should handle dictionaries with varying lengths of lists and ensure that the resulting dictionary main...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def combine_lists_to_tuples(dictionary: Dict[str, List[int]]) -> Dict[str, Tuple[int, ...]]: """ Combine values in a dictionary of lists into a dictionary of tuples. Args: dicti...
code_exercise_27k
4,585
Write a Python function to compute the union of multiple sorted lists, preserving the original order of elements. The function should efficiently merge the lists while maintaining the sorted order and avoiding duplicates. The code should start with: ```python from typing import List def compute_union_sorted_lists(list...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_union_sorted_lists(lists: List[List[int]]) -> List[int]: """ Compute the union of multiple sorted lists, preserving the original order of elements. Args: lists (List[List[int]]):...
code_exercise_27k
4,586
Write a Python function to create a dictionary where the keys are strings from a given list and the values are the cumulative count of their lengths. The cumulative count should be calculated as the sum of the lengths of all strings processed so far, including the current string. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_cumulative_length_dict(strings: List[str]) -> Dict[str, int]: """ Create a dictionary with the keys as strings and the values as the cumulative count of their lengths. Args: ...
code_exercise_27k
4,593
Write a Python function to compute the intersection of two sorted lists using the merge technique. The function should return a new list containing only the elements that are present in both input lists, without duplicates. The function should handle lists of integers and ensure that both input lists are sorted. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_intersection(sorted_list1: List[int], sorted_list2: List[int]) -> List[int]: """ Computes the intersection of two sorted lists using the merge technique. Args: sorted_list1 (List...
code_exercise_27k
4,594
Write a Python function to compute the summation of two dictionaries while ignoring common keys. The function should take two dictionaries as input and return a new dictionary where the values of common keys are summed up, and non-common keys are included as they are. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sum_dicts_ignore_common(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]: """ Computes the summation of two dictionaries while ignoring common keys. Args: dict1 (Dict[str,...
code_exercise_27k
4,598
Write a Python function to find the union of two sorted lists, using the merge technique and removing duplicates. The function should efficiently merge the two lists while ensuring that all elements in the resulting list are unique. The code should start with: ```python from typing import List def find_union_of_sorted...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union_of_sorted_lists(lst1: List[int], lst2: List[int]) -> List[int]: """ Find the union of two sorted lists by merging and removing duplicates. Args: lst1 (List[int]): The first so...
code_exercise_27k
4,599
Write a Python function to find the range of elements in a given set of numbers. The range is defined as the difference between the maximum and minimum values in the set. If the set is empty, the function should return `None`. The code should start with: ```python def find_range(s: set) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_range(s: set) -> tuple: """ Find the range of elements in a set. Args: - s: A set of numbers. Returns: - A tuple containing the minimum and maximum values in the set (range). - None if the set is e...
code_exercise_27k
4,600
Write a Python function to filter a dictionary by a list of keys, returning a new dictionary that only includes the specified keys. If a key in the list does not exist in the original dictionary, it should be ignored. The function should handle various iterable types (list, set, tuple) for the keys. The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Iterable, Any def filter_dictionary_by_keys(original_dict: Dict[Any, Any], keys: Iterable[Any]) -> Dict[Any, Any]: """ Filters a dictionary by a list of keys, returning a new dictionary with only the sp...
code_exercise_27k
4,602
Write a Python function to check if a given key exists in a dictionary and return the corresponding value if the key exists. If the key does not exist, return a default value provided by the user. The function should handle cases where the dictionary or the key is `None`. The code should start with: ```python from typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Optional def get_value_or_default(dictionary: Optional[dict], key: Any, default: Any) -> Any: """ Check if a given key exists in a dictionary and return the corresponding value. If the key does not e...
code_exercise_27k
4,603
Write a Python function to calculate the standard deviation of a given list of numbers. The function should handle the calculation of the mean, the sum of squared differences from the mean, the variance, and finally the standard deviation. The code should start with: ```python from typing import List import math def c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def calculate_standard_deviation(numbers: List[float]) -> float: """ Calculate the standard deviation of a list of numbers. Args: numbers (List[float]): A list of numbers for whi...
code_exercise_27k
4,607
Write a Python function to calculate the variance of elements in a given set of numeric values. The function should handle sets with fewer than two elements by returning a variance of 0. The code should start with: ```python def calculate_variance(data: set) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_variance(data: set) -> float: """ Calculate the variance of elements in a given set of numeric values. The variance is a measure of how spread out the numbers in a set are. If the set contains fewer than t...
code_exercise_27k
4,609
Write a Python function to merge two dictionaries into a new dictionary. If both dictionaries have the same key, the value from the second dictionary should overwrite the value from the first dictionary. The function should handle any type of dictionary values, including nested dictionaries. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def merge_dicts(dict1: Dict[Any, Any], dict2: Dict[Any, Any]) -> Dict[Any, Any]: """ Merge two dictionaries into a new dictionary. If both dictionaries have the same key, the value from the seco...
code_exercise_27k
4,611
Write a Python function to compute the intersection of two sorted lists, without using any built-in functions or data structures. The function should return a new list containing elements that are present in both input lists, maintaining the sorted order. The code should start with: ```python from typing import List ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_intersection(list1: List[int], list2: List[int]) -> List[int]: """ Computes the intersection of two sorted lists without using any built-in functions or data structures. Args: li...
code_exercise_27k
4,614
Write a Python function to determine if two dictionaries have any common keys. The function should return `True` if there is at least one common key between the two dictionaries, and `False` otherwise. The code should start with: ```python def have_common_keys(dict1: dict, dict2: dict) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def have_common_keys(dict1: dict, dict2: dict) -> bool: """ Determine if two dictionaries have any common keys. Args: dict1 (dict): The first dictionary. dict2 (dict): The second dictionary. Returns: ...
code_exercise_27k
4,617
Write a Python function to remove a specific key-value pair from a given dictionary. If the key does not exist in the dictionary, the function should return the dictionary unchanged. The function should handle dictionaries with various data types as keys and values. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict def remove_key_value_pair(dictionary: Dict[Any, Any], key: Any) -> Dict[Any, Any]: """ Remove a specific key-value pair from a given dictionary. Args: dictionary (Dict[Any, Any]): The d...
code_exercise_27k
4,620
Write a Python function to generate all possible permutations of elements in a given list. The function should handle lists of any length, including empty lists. The permutations should be returned as a list of lists, where each inner list represents a unique permutation of the input list. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_permutations(elements: List) -> List[List]: """ Generate all possible permutations of elements in a given list. Args: elements (List): The list of elements for which permutation...
code_exercise_27k
4,622
Write a Python function to calculate the sum of all values in a given dictionary. The dictionary may contain values of different types, but only numeric values (integers and floats) should be included in the sum. Non-numeric values should be ignored. The function should return the sum of all numeric values. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union def sum_numeric_values(dictionary: Dict[Union[str, int], Union[int, float, str]]) -> Union[int, float]: """ Calculate the sum of all numeric values in a dictionary. Args: dictionary (...
code_exercise_27k
4,626
Write a Python function to triple each element in a given list using the `map` function. The function should take a list of integers as input and return a new list where each element is tripled. The code should start with: ```python from typing import List def triple_elements(lst: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def triple_elements(lst: List[int]) -> List[int]: """ Triple each element in a given list using the map function. Args: lst (List[int]): The input list of integers. Returns: Lis...
code_exercise_27k
4,629
Write a Python function to compute the union of two lists, where duplicates are counted multiple times. The function should take two lists as input and return a new list that contains all elements from both lists, preserving the order and frequency of each element as they appear in the input lists. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def union_with_duplicates(list1: List[int], list2: List[int]) -> List[int]: """ Compute the union of two lists, where duplicates are counted multiple times. Args: list1 (List[int]): The firs...
code_exercise_27k
4,630
Write a Python function to convert all the names in a given list to uppercase using the `map` function. The function should handle input validation to ensure that the input is a list. If the input is not a list, the function should raise a `TypeError`. The code should start with: ```python from typing import List def ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_names_to_upper(names: List[str]) -> List[str]: """ Convert all names in a list to uppercase using the map function. Args: names (List[str]): List of names to be converted. R...
code_exercise_27k
4,631
Write a Python function to find the union of two lists, where duplicates are counted multiple times and removing duplicates. The function should return a list that contains all unique elements from both lists, preserving the order of their first appearance. The code should start with: ```python from typing import List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union(list1: List[int], list2: List[int]) -> List[int]: """ Finds the union of two lists, counting duplicates and removing duplicates while preserving the order of their first appearance. A...
code_exercise_27k
4,632
Write a Python function to find the cube of each element in a list using the `map` function. The function should take a list of numbers as input and return a new list containing the cube of each element. The code should start with: ```python from typing import List def cube_list(numbers: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cube_list(numbers: List[int]) -> List[int]: """ Finds the cube of each element in a given list. Args: numbers (List[int]): The list of numbers. Returns: List[int]: A new lis...
code_exercise_27k
4,634
Write a Python function to compute the union of multiple lists, where duplicates are counted multiple times. The function should take a list of lists as input and return a single list containing all elements from the input lists, preserving the order of their first appearance and including all duplicates. The code sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_union_of_lists(lists: List[List[int]]) -> List[int]: """ Compute the union of multiple lists, where duplicates are counted multiple times. Args: lists (List[List[int]]): A list o...
code_exercise_27k
4,637
Write a Python function to calculate the square of each number in a given list using the `map` function. The function should take a list of numbers as input and return a new list containing the squares of the numbers. The code should start with: ```python from typing import List def calculate_squares(numbers: List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_squares(numbers: List[int]) -> List[int]: """ Calculate the square of each number in the given list using the map function. Args: numbers (List[int]): A list of integers for wh...
code_exercise_27k
4,642
Write a Python function to calculate the number of possible combinations of selecting `k` elements from a set of size `n` using an efficient approach. The function should handle edge cases such as when `k` is greater than `n` or when `k` is negative. The code should start with: ```python def combinations_count(n: int, ...
Here is the Python code to solve the given problem in the markdown block: ```python def combinations_count(n: int, k: int) -> int: """ Calculate the number of possible combinations of selecting k elements from a set of size n. Args: n (int): The size of the set. k (int): The number of eleme...
code_exercise_27k
4,643
Write a Python function to convert a list of strings to uppercase using the `map` function. The function should take a list of strings as input and return a new list with all the strings converted to uppercase. The code should start with: ```python from typing import List def convert_strings_to_uppercase(strings: List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_strings_to_uppercase(strings: List[str]) -> List[str]: """ Convert a list of strings to uppercase. Args: strings (List[str]): A list of strings to be converted to uppercase. ...
code_exercise_27k
4,646
Write a Python function to reverse each element in a given list of strings using the `map` function. The function should return a new list containing the reversed strings. The code should start with: ```python from typing import List def reverse_each_element(lst: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_each_element(lst: List[str]) -> List[str]: """ Reverse each element in a list of strings using the map function. Args: lst (List[str]): The input list of strings. Returns: ...
code_exercise_27k
4,648
Write a Python function to find the union of two lists, where duplicates are counted and sorted based on their counts, and then removing duplicates. The function should return a list of unique elements sorted by their frequency in descending order. The code should start with: ```python from typing import List def fin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_union_sorted_count(list1: List[int], list2: List[int]) -> List[int]: """ Finds the union of two lists, counting and sorting the duplicates based on their counts, and then removing duplicates. ...
code_exercise_27k
4,649
Write a Python function to calculate the absolute value of each number in a given list of numbers using the `map` function. The function should return a new list containing the absolute values of the numbers. The code should start with: ```python from typing import List def calculate_absolute_values(numbers: List[int]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_absolute_values(numbers: List[int]) -> List[int]: """ Calculates the absolute value of each number in the given list. Args: numbers (List[int]): A list of integers. Return...