source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
21,608
Write a Python function to iterate over a given list and return a new list containing each element from the original list, preserving the order. The function should handle lists of any data type and length. The code should start with: ```python from typing import List, Any def iterate_and_collect(input_list: List[Any]...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Any def iterate_and_collect(input_list: List[Any]) -> List[Any]: """ Iterates over a given list and returns a new list containing each element from the original list, preserving the order. Args: ...
evol_instruct_66k
21,611
Write a Python function to calculate the factorial of a given non-negative integer using memoization to optimize the recursive calls. The function should store previously computed factorial values in a dictionary to avoid redundant calculations. The code should start with: ```python def factorial_memoized(n: int, memo...
Here is the Python code to solve the given problem in the markdown block: ```python def factorial_memoized(n: int, memo: dict = None) -> int: """ Calculate the factorial of a given non-negative integer using memoization. Args: n (int): The non-negative integer for which to calculate the factorial. ...
evol_instruct_66k
21,616
Write a Python function to dissect a continuous sequence of text into its individual constituent alphabetic elements, ignoring any non-alphabetic characters. The function should return a list of these alphabetic characters. The code should start with: ```python from typing import List def dissect_text(text: str) -> L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def dissect_text(text: str) -> List[str]: """ Dissects a continuous sequence of text into its individual constituent alphabetic elements. Args: text (str): The input text to be dissected. ...
evol_instruct_66k
21,618
Write a Python function to map an integer to its corresponding day of the week, where 1 represents Monday and 7 represents Sunday. If the input integer is outside the range [1, 7], the function should return an error message indicating an invalid day number. The code should start with: ```python def get_day_of_week(da...
Here is the Python code to solve the given problem in the markdown block: ```python def get_day_of_week(day: int) -> str: """ Maps an integer to its corresponding day of the week. Args: day (int): An integer representing the day of the week (1 for Monday, 2 for Tuesday, ..., 7 for Sunday). Ret...
evol_instruct_66k
21,619
Write a Python function to determine if a given number is even or odd. If the number is even, the function should return "Yes, it's even". If the number is odd, the function should return "No, it's not even". The function should handle both positive and negative integers. The code should start with: ```python def chec...
Here is the Python code to solve the given problem in the markdown block: ```python def check_even_or_odd(number: int) -> str: """ Determines if a given number is even or odd and returns a corresponding message. Args: number (int): The number to be checked. Returns: str: A string indic...
evol_instruct_66k
21,627
Write a Python function to calculate the Least Common Multiple (LCM) of two integers `x` and `y` using an advanced computation technique, while incorporating additional restrictions. The function should handle the constraints where `1 <= x, y <= 10^9`. The code should start with: ```python def lcm(x: int, y: int) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python import math def lcm(x: int, y: int) -> int: """ Calculate the Least Common Multiple (LCM) of two integers x and y using an advanced computation technique. Args: x (int): The first integer, with the constraint 1 <= ...
evol_instruct_66k
21,638
Write a Python function to remove a specified key-value pair from a given dictionary. The function should handle cases where the key does not exist in the dictionary without raising an error. The code should start with: ```python from typing import Dict, Any def remove_key(dictionary: Dict[Any, Any], key_to_remove: An...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def remove_key(dictionary: Dict[Any, Any], key_to_remove: Any) -> Dict[Any, Any]: """ Removes a specified key-value pair from the given dictionary. Args: dictionary (Dict[Any, Any]): Th...
evol_instruct_66k
21,645
Create a Python decorator that logs the execution time of a function and modifies its return value by appending a prefix to it. The decorator should also handle exceptions gracefully by logging the error message and returning `None` in case of an exception. The code should start with: ```python import time import logg...
Here is the Python code to solve the given problem in the markdown block: ```python import time import logging # Configure logging logging.basicConfig(level=logging.INFO) def log_and_modify_decorator(func): """ A decorator that logs the execution time of a function and modifies its return value by appending a...
evol_instruct_66k
21,657
Write a Python function to split a given string into its component words and return them as a list. The function should handle various edge cases, such as strings with leading or trailing spaces, multiple spaces between words, and empty strings. The code should start with: ```python from typing import List def split_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string_into_words(s: str) -> List[str]: """ Splits a given string into its component words and returns them as a list. Args: s (str): The input string to be split into words. ...
evol_instruct_66k
21,663
Write a Python function to calculate the product of the digits of a given number. The function should handle both positive and negative integers. If the number is negative, the function should ignore the negative sign and calculate the product of the digits. The code should start with: ```python def product_of_digits(...
Here is the Python code to solve the given problem in the markdown block: ```python def product_of_digits(n: int) -> int: """ Calculate the product of the digits of a given number. Args: n (int): The number whose digits' product is to be calculated. Returns: int: The product of the dig...
evol_instruct_66k
21,671
Write a Python function to increase an initial score by a specified odd increment and return the final score. The function should ensure that the increment is an odd number and handle the case where the increment is not odd by returning the initial score unchanged. The code should start with: ```python def increase_sc...
Here is the Python code to solve the given problem in the markdown block: ```python def increase_score_by_odd_increment(initial_score: int, increment: int) -> int: """ Increases the initial score by a specified odd increment and returns the final score. If the increment is not odd, the initial score is retu...
evol_instruct_66k
21,673
Write a Python function to determine if two binary trees are flip equivalent. Two binary trees are considered flip equivalent if one can be made identical to the other by performing a certain number of flip operations. A flip operation involves selecting any node and interchanging the positions of its left and right ch...
Here is the Python code to solve the given problem in the markdown block: ```python class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def are_flip_equivalent(root1: TreeNode, root2: TreeNode) -> bool: """ Determine i...
evol_instruct_66k
21,680
Write a Python function to perform Breadth-First Search (BFS) and Depth-First Search (DFS) traversals on a given tree represented as an adjacency list. The tree has a root node and several child nodes, and the traversal should start from the root node. The DFS traversal should consider the left-most children first. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import deque def breadth_first_search(tree: Dict[str, List[str]], root: str) -> List[str]: """ Perform a Breadth-First Search (BFS) traversal on a tree represented as an adjacency ...
evol_instruct_66k
21,681
Write a Python function to detect duplicates in a tuple and return a dictionary with the elements that have duplicates as keys and their respective counts as values. The function should handle tuples containing both string and integer elements. The code should start with: ```python from typing import Tuple, Dict, Union...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Dict, Union def detect_duplicates(T: Tuple[Union[int, str], ...]) -> Dict[Union[int, str], int]: """ Detects duplicates in a tuple and returns a dictionary with elements that have duplicates as keys an...
evol_instruct_66k
21,702
Write a Python function to calculate the accumulated total of an arbitrary number of numerical parameters. The function should accept a variable number of arguments and return the sum of all the provided arguments. The code should start with: ```python def accumulate_total(*args) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def accumulate_total(*args) -> float: """ Calculate the accumulated total of an arbitrary number of numerical parameters. Args: *args: A variable number of numerical arguments. Returns: float: The sum o...
evol_instruct_66k
21,720
Write a Python function to determine if a specified number (integer or floating point) exists within a multi-dimensional numerical array and to count the total number of occurrences of the specified number in the array. The function should be able to handle arrays with arbitrary depth. The code should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List def count_occurrences(arr: Union[List, int, float], x: Union[int, float]) -> int: """ Counts the total number of occurrences of a specified number in a multi-dimensional numerical array. Args...
evol_instruct_66k
21,723
Write a Python function to determine the frequency of each word in a given sentence. The function should be case-insensitive, meaning "This" and "this" should be considered the same word. The function should return a dictionary where the keys are the words and the values are their respective frequencies. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict from collections import Counter def word_frequency(sentence: str) -> Dict[str, int]: """ Calculate the frequency of each word in a given sentence. Args: sentence (str): The input sentence fr...
evol_instruct_66k
21,724
Write a Python function to sort a list of tuples containing a string name and a decimal value using the bubble sort algorithm. The sorting should first be based on the decimal value in ascending order. If two tuples have the same decimal value, then sort them alphabetically based on the string name in ascending order. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sort_tuples(lst: List[Tuple[str, float]]) -> List[Tuple[str, float]]: """ Sorts a list of tuples containing a string name and a decimal value using bubble sort. The sorting is primarily ba...
evol_instruct_66k
21,733
Write a Python function to generate a stochastic sequence of n distinct numerals, where every entry is not predictable with complete certainty based on the previous entries. The numerals should be integers between 0 and 9 (inclusive). The function should return the sequence as a 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 List import random def generate_stochastic_sequence(n: int) -> List[int]: """ Generates a stochastic sequence of n distinct numerals between 0 and 9. Args: n (int): The number of distinct numeral...
evol_instruct_66k
21,749
Write a Python function to display the positional parameters passed to it. The function should accept a variable number of arguments and print each argument on a new line. The code should start with: ```python from typing import Any def display_positional_parameters(*args: Any) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any def display_positional_parameters(*args: Any) -> None: """ Displays each positional parameter passed to the function on a new line. Args: *args (Any): A variable number of arguments of any ty...
evol_instruct_66k
21,754
Write a Python function to compute the summation of the constituent integer elements within a given list. The function should handle lists of arbitrary length and ensure that the summation is performed correctly. The code should start with: ```python from typing import List def sum_list_elements(my_list: List[int]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_list_elements(my_list: List[int]) -> int: """ Computes the summation of the integer elements within a given list. Args: my_list (List[int]): A list of integers whose elements are to ...
evol_instruct_66k
21,787
Write a Python function to generate a sequence of Subversion (SVN) commands that create a new branch named "features" from the main branch (trunk) in a remote software repository labeled "my-software". The function should return a list of these commands as strings. 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 generate_svn_branch_commands(repo_path: str) -> List[str]: """ Generates a sequence of Subversion (SVN) commands to create a new branch named "features" from the trunk. Args: repo_path (...
evol_instruct_66k
21,790
Write a Python function to identify the non-overlapping elements in two unorganized lists of strings and provide their frequency. The function should return two dictionaries, each containing the unique elements from one list and their respective frequencies. The code should start with: ```python from typing import Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import Counter def find_unique_with_frequency(list1: List[str], list2: List[str]) -> (Dict[str, int], Dict[str, int]): """ Identifies the non-overlapping elements in two unorganize...
evol_instruct_66k
21,792
Write a Python function to calculate the volume of a rectangular prism given its length, width, and height. The function should return the volume in cubic units. The code should start with: ```python def calculate_volume(length: float, width: float, height: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def calculate_volume(length: float, width: float, height: float) -> float: """ Calculate the volume of a rectangular prism given its length, width, and height. Args: length (float): The length of the rectangular p...
evol_instruct_66k
21,794
Write a Python function to find the smallest absolute value among a list of negative floating point numbers. The function should handle an empty list by returning `None`. The code should start with: ```python from typing import List, Optional def find_smallest_absolute_value(numbers: List[float]) -> Optional[float]: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_smallest_absolute_value(numbers: List[float]) -> Optional[float]: """ Find the smallest absolute value among a list of negative floating point numbers. Args: numbers (List...
evol_instruct_66k
21,799
Write a Python function to remove all empty strings from a given list of strings. The function should return a new list that contains only the non-empty strings from the original list. The code should start with: ```python from typing import List def remove_empty_strings(string_list: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_empty_strings(string_list: List[str]) -> List[str]: """ Removes all empty strings from the given list of strings. Args: string_list (List[str]): The list of strings from which to ...
evol_instruct_66k
21,803
Write a Python function to find the index of a target value in a sorted array using the binary search algorithm. If the target value is not found in the array, the function should return -1. The array is guaranteed to be sorted in ascending order. The code should start with: ```python from typing import List def bina...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(arr: List[int], target: int) -> int: """ Find the index of a target value in a sorted array using the binary search algorithm. Args: arr (List[int]): A sorted list of integ...
evol_instruct_66k
21,809
Write a Python function to count the number of vowels in a given string. The function should be case-insensitive and should consider both uppercase and lowercase vowels. The code should start with: ```python def count_vowels(s: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_vowels(s: str) -> int: """ Counts the number of vowels in a given string. Args: s (str): The input string to count vowels from. Returns: int: The total number of vowels in the string. """ ...
evol_instruct_66k
21,825
Write a Python function to generate a list of all prime numbers up to and including a given integer `n` using the Sieve of Eratosthenes algorithm. The function should return a list of these prime numbers. The code should start with: ```python from typing import List def sieve_of_eratosthenes(n: int) -> List[int]: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sieve_of_eratosthenes(n: int) -> List[int]: """ Generate a list of all prime numbers up to and including a given integer n using the Sieve of Eratosthenes algorithm. Args: n (int): The u...
evol_instruct_66k
21,844
Write a Python function to reverse the order of elements in a given list. The function should return a new list with the elements in the reversed order. The original list should remain unchanged. The code should start with: ```python from typing import List def reverse_list(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(arr: List[int]) -> List[int]: """ Reverses the order of elements in the given list and returns a new list with the reversed elements. Args: arr (List[int]): The input list t...
evol_instruct_66k
21,846
Write a Python function to calculate the mean of a given 2D array. The function should handle any rectangular 2D array of integers. The code should start with: ```python from typing import List def calculate_mean_2d(arr: List[List[int]]) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_mean_2d(arr: List[List[int]]) -> float: """ Calculate the mean of a given 2D array of integers. Args: arr (List[List[int]]): A 2D list of integers. Returns: float:...
evol_instruct_66k
21,847
Write a Python function to alternate the positions of consecutive elements in a given list using a recursive approach. The function should handle the common runtime errors encountered during the swapping process, such as 'index out of bounds' errors. The function should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def alternate_positions(lst: List[int], index: int = 0) -> List[int]: """ Alternates the positions of consecutive elements in the given list using a recursive approach. Args: lst (List[int])...
evol_instruct_66k
21,876
Write a Python function to generate a SQL query that selects the top 5 most expensive items from a table, filtered by additional conditions: the items must be in stock, have been reviewed at least 10 times, and the reviews have an average rating of four or above. The query should also display the name, price, average r...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_top_5_expensive_items_query(table_name: str) -> str: """ Generates a SQL query to select the top 5 most expensive items from a table, filtered by additional conditions: the items must be in stock, have been ...
evol_instruct_66k
21,878
Write a Python function to determine if a given number is a prime number. The function should return `True` if the number is prime and `False` otherwise. The function should be efficient and handle edge cases such as numbers less than 2. The code should start with: ```python def is_prime(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(num: int) -> bool: """ Determine if a given number is a prime number. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ""...
evol_instruct_66k
21,879
Write a Python function to check if a list of numerical values is in ascending order. The function should handle exceptions for inputs that are not numeric and lists that are empty. The function should return `False` if the list is empty or contains non-numeric values, and `True` if the list is in ascending order. If t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def is_ascending_order(lst: List[Union[int, float]]) -> bool: """ Check if a list of numerical values is in ascending order. Args: lst (List[Union[int, float]]): The list of numerical...
evol_instruct_66k
21,893
Write a Python function to isolate and return the constituent labeled "Pineapple" from a given tuple data structure that embodies distinct fruit names. If "Pineapple" is not present in the tuple, the function should return `None`. The code should start with: ```python from typing import Tuple, Optional def isolate_pi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Optional def isolate_pineapple(fruits: Tuple[str, ...]) -> Optional[str]: """ Isolate and return the constituent labeled "Pineapple" from the given tuple of fruit names. If "Pineapple" is not prese...
evol_instruct_66k
21,919
Write a Python function to calculate the surface area of an n-dimensional hypercube given its dimension `n` and edge length `d`. The function should be able to handle any positive integer dimension and edge length. The code should start with: ```python def hypercube_surface_area(n: int, d: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def hypercube_surface_area(n: int, d: float) -> float: """ Calculate the surface area of an n-dimensional hypercube given its dimension and edge length. Args: n (int): The dimension of the hypercube. Must be a posit...
evol_instruct_66k
21,933
Write a Python function to calculate the cumulative total of a given list of integers without using any pre-built functions like `sum()`. The function should iterate through the list and accumulate the total sum. The code should start with: ```python from typing import List def cumulative_total(nums: List[int]) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_total(nums: List[int]) -> int: """ Calculate the cumulative total of a list of integers without using pre-built functions. Args: nums (List[int]): A list of integers for which...
evol_instruct_66k
21,957
Write a Python function to sort a given list of integers in descending order. The function should return the sorted list. The code should start with: ```python from typing import List def sort_descending(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 sort_descending(numbers: List[int]) -> List[int]: """ Sorts a given list of integers in descending order. Args: numbers (List[int]): The list of integers to be sorted. Returns: ...
evol_instruct_66k
21,958
Write a Python function to calculate the nth Fibonacci number using a dynamic programming approach. The function should handle large values of n efficiently and ensure that the calculation is not affected by race conditions. Additionally, implement error handling to deal with potential issues such as invalid input (e.g...
Here is the Python code to solve the given problem in the markdown block: ```python def fibonacci(n: int) -> int: """ Calculate the nth Fibonacci number using dynamic programming. Args: n (int): The position in the Fibonacci sequence to calculate. Returns: int: The nth Fibonacci number...
evol_instruct_66k
21,961
Write a Python function to sort a dictionary of dictionaries by their nested values in ascending order. The outer dictionary keys represent string identification codes while the inner keys stand for various characteristics such as 'name', 'age', and 'salary'. Sort by 'age' first, and if two 'age' values are the same, u...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def sort_nested_dictionary(dictionary: Dict[str, Dict[str, Any]]) -> Dict[str, Dict[str, Any]]: """ Sorts a dictionary of dictionaries by their nested values in ascending order. The outer dictio...
evol_instruct_66k
21,973
Write a Python function to merge two given arrays of numerical elements and return a new array where each element is the sum of the corresponding elements from the two input arrays. If the arrays are of different lengths, the function should handle the extra elements by appending them to the result array as they are. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_and_sum_arrays(array1: List[int], array2: List[int]) -> List[int]: """ Merges two arrays of numerical elements and returns a new array where each element is the sum of the corresponding element...
evol_instruct_66k
22,005
Write a Python function to generate a list of prime numbers between two given numbers using the Sieve of Eratosthenes algorithm. The function should efficiently mark non-prime numbers and return a list of prime numbers within the specified range. The code should start with: ```python from typing import List def gener...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_primes_in_range(start: int, end: int) -> List[int]: """ Generate a list of prime numbers between the given start and end values (inclusive) using the Sieve of Eratosthenes algorithm. Ar...
evol_instruct_66k
22,007
Write a Python function to generate a unique sequence of 24 characters containing only the letters 'x', 'y', 'z', and 'w'. The sequence should not contain any consecutive repeated sequences of 3 characters or more. For instance, 'xxx', 'yyy', 'zzz', 'www', 'xyx', 'xzx', 'yzy', and so on should not appear in the sequenc...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_unique_sequence(length: int) -> str: """ Generates a unique sequence of the specified length containing only the letters 'x', 'y', 'z', and 'w'. The sequence does not conta...
evol_instruct_66k
22,023
Write a Python function to perform a multiplication operation between an integer and a string that represents a number, and return the result as an integer. The function should handle the conversion of the string to an integer before performing the multiplication. Additionally, provide a function to repeat a string a s...
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_int_and_string(x: int, y: str) -> int: """ Multiplies an integer by a string that represents a number. Args: x (int): The integer to be multiplied. y (str): The string representing a number. ...
evol_instruct_66k
22,030
Write a Python function to determine if a given integer is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). The function should return `True` if the number is perfect and `False` otherwise. The code should start with: ```python def is_perfect_n...
Here is the Python code to solve the given problem in the markdown block: ```python def is_perfect_number(n: int) -> bool: """ Determines if a given integer is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). Args: n (...
evol_instruct_66k
22,044
Write a Python function to find all rows in a given list of dictionaries where at least one of the specified columns (minimum five) contains a null value. The function should return a list of dictionaries representing the rows that meet the criteria. The code should start with: ```python from typing import List, Dict ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def find_rows_with_nulls(data: List[Dict[str, any]], columns: List[str]) -> List[Dict[str, any]]: """ Find all rows in the given list of dictionaries where at least one of the specified columns con...
evol_instruct_66k
22,050
Write a Python function to encode and decode strings using the Base64 encoding scheme. The function should take a string as input and return the encoded or decoded string based on the operation specified ('encode' or 'decode'). The function should handle both encoding and decoding operations efficiently. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python import base64 def base64_encode_decode(input_string: str, operation: str) -> str: """ Encodes or decodes a given string using the Base64 encoding scheme. Args: input_string (str): The string to be encoded or decode...
evol_instruct_66k
22,058
Write a Python function to check if an array contains an even number. The function should return `True` if the array contains at least one even number, and `False` otherwise. The code should start with: ```python from typing import List def contains_even_number(arr: List[int]) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def contains_even_number(arr: List[int]) -> bool: """ Check if the given array contains at least one even number. Args: arr (List[int]): The array of integers to check. Returns: ...
evol_instruct_66k
22,071
Write a Python function to count the number of vowels in a given alphanumeric phrase. The function should be case-insensitive, meaning both uppercase and lowercase vowels should be counted. The code should start with: ```python def count_vowels(phrase: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_vowels(phrase: str) -> int: """ Count the number of vowels in the given alphanumeric phrase. Args: phrase (str): The alphanumeric phrase to count vowels in. Returns: int: The number of vowels ...
evol_instruct_66k
22,074
Refactor the given Python code to eliminate redundancy and improve efficiency. Identify and correct any logical discrepancies in the code. The task is to rewrite the code so that it performs the same operations but in a more efficient and logically sound manner. The code should start with: ```python def calculate_y(x: ...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_y(x: int) -> int: """ Calculate the value of y based on the value of x. Args: x (int): The input value used to determine the value of y. Returns: int: The calculated value of y. """ ...
evol_instruct_66k
22,113
Write a Python function to calculate the Levenshtein Distance between two strings. The Levenshtein Distance is defined as the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other. The function should be efficient and use dynamic programming to a...
Here is the Python code to solve the given problem in the markdown block: ```python def levenshtein_distance(string1: str, string2: str) -> int: """ Calculate the Levenshtein Distance between two strings. The Levenshtein Distance is the minimum number of single-character edits (insertions, deletions, o...
evol_instruct_66k
22,115
Write a Python function to extract all email addresses from a given string using a corrected regular expression. The function should handle various email formats and domain names. The code should start with: ```python import re from typing import List def extract_emails(text: str) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def extract_emails(text: str) -> List[str]: """ Extracts all email addresses from the given text using a corrected regular expression. Args: text (str): The input string containing...
evol_instruct_66k
22,139
Write a Python function to determine if a specific character is present in a given string. The function should return a boolean value indicating whether the character is found in the string. The code should start with: ```python def is_character_in_string(word: str, character: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_character_in_string(word: str, character: str) -> bool: """ Determines if a specific character is present in a given string. Args: word (str): The string in which to search for the character. characte...
evol_instruct_66k
22,143
Write a Python function to perform a stable sort on a list of floating-point numbers, ensuring that the relative position of equal numbers remains unchanged. Additionally, handle potential rounding errors in floating-point calculations. The function should start with: ```python from typing import List def stable_sort_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def stable_sort_with_rounding(lst: List[float]) -> List[float]: """ Perform a stable sort on a list of floating-point numbers, ensuring that the relative position of equal numbers remains unchanged. ...
evol_instruct_66k
22,147
Write a Python function to generate and display a frequency distribution table for a given list of categorical data. The function should count the occurrences of each unique category in the list and return a dictionary where the keys are the categories and the values are their respective counts. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def frequency_distribution(data: List[str]) -> Dict[str, int]: """ Generates a frequency distribution table for a given list of categorical data. Args: data (List[str]): A list of stri...
evol_instruct_66k
22,155
Write a Python function to determine if the first string in a tuple of two string literals is an anagram of the second string. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should return a boolean value...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple from collections import Counter def are_anagrams(strings: Tuple[str, str]) -> bool: """ Determines if the first string in the tuple is an anagram of the second string. Args: strings (Tuple[...
evol_instruct_66k
22,195
Write a Python function to calculate the first `n` Fibonacci numbers. The function should return a list of the first `n` Fibonacci numbers. The code should start with: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: """ Generate the first n Fibonacci numbers. Args: n (int): The number of Fibonacci numbers to generate. Returns: List[int]: A list c...
evol_instruct_66k
22,206
Write a Python function to modify the elements of a given list by applying a specified transformation function directly within the list, without creating a new list. The function should take a list and a transformation function as arguments and return the modified list. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def modify_list_in_place(lst: List[int], transform_func: Callable[[int], int]) -> List[int]: """ Modifies the elements of a given list by applying a specified transformation function directly w...
evol_instruct_66k
22,212
Write a Python function to encode a string by shifting each character two places to the right in the alphabet, and another function to decode the encoded string by shifting each character two places to the left. Ensure that the decoding function correctly handles overflow conditions (characters beyond 'z' or 'Z'). Addi...
Here is the Python code to solve the given problem in the markdown block: ```python def encode_string(text: str) -> str: """ Encodes the given string by shifting each character two places to the right in the alphabet. Args: text (str): The string to be encoded. Returns: str: The encode...
evol_instruct_66k
22,213
Write a Python function to calculate all the distinct factors of a given positive integer efficiently. The function should return a list of factors in ascending order. The code should start with: ```python from typing import List def calculate_factors(num: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def calculate_factors(num: int) -> List[int]: """ Calculate all distinct factors of a given positive integer efficiently. Args: num (int): The positive integer for which to calcu...
evol_instruct_66k
22,215
Write a Python function to calculate the product of all unique dictionary keys that can be converted to integers, while handling and reporting any non-integer keys as exceptions. The function should not modify the input dictionary during computation. Additionally, provide a piece of erroneous code that disregards non-i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def product_of_integer_keys(d: Dict[str, str]) -> int: """ Calculate the product of all unique dictionary keys that can be converted to integers. Non-integer keys are caught and reported as exception...
evol_instruct_66k
22,221
Write a Python function to find and return the common elements present in all three given arrays of integers. The function should handle arrays of different sizes and ensure that the output is sorted in ascending order. The function should start with: ```python from typing import List def find_common_elements(arr1: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(arr1: List[int], arr2: List[int], arr3: List[int]) -> List[int]: """ Find and return the common elements present in all three given arrays of integers. Args: arr1 (L...
evol_instruct_66k
22,228
Write a Python function to calculate the Euclidean distance between two points in a multidimensional space. The function should accept two tuples representing the coordinates of the points. Ensure the function handles exceptions gracefully, such as when the input tuples do not have the same dimensions. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Optional import math def euclidean_distance(pointA: Tuple[float, ...], pointB: Tuple[float, ...]) -> Optional[float]: """ Calculate the Euclidean distance between two points in a multidimensional space...
evol_instruct_66k
22,260
Write a Python function to perform a linear search on a given list to find the index of a specified element. If the element is not found, return -1. The function should handle lists of any data type and be efficient for small to moderately sized lists. The code should start with: ```python from typing import List, Any...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def linear_search(arr: List[Any], x: Any) -> int: """ Perform a linear search to find the index of a specified element in a list. Args: arr (List[Any]): The list in which to search for ...
evol_instruct_66k
22,269
Write a Python function to merge two pre-sorted arrays into a single sorted array without using any external libraries. The function should efficiently combine the two arrays by leveraging their pre-sorted nature. The code should start with: ```python from typing import List def merge_sorted_arrays(arr1: List[int], a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]: """ Merges two pre-sorted arrays into a single sorted array. Args: arr1 (List[int]): The first pre-sorted array. ...
evol_instruct_66k
22,271
Write a Python function to find the third item from the end in a given tuple. The function should take a tuple as input and return the third item from the end. If the tuple has fewer than three elements, the function should return `None`. The code should start with: ```python from typing import Tuple, Optional def th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Optional def third_from_end(colors: Tuple[str]) -> Optional[str]: """ Returns the third item from the end in a given tuple. Args: colors (Tuple[str]): A tuple of strings from which to find...
evol_instruct_66k
22,275
Write a Python function to count the number of vowel characters in a given string. The function should be case-insensitive and should consider both uppercase and lowercase vowels. The code should start with: ```python def count_vowels(sentence: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_vowels(sentence: str) -> int: """ Count the number of vowel characters in a given string. Args: sentence (str): The input string to count vowels in. Returns: int: The number of vowel character...
evol_instruct_66k
22,276
Write a Python function to perform a binary search on a sorted list to find the index of a given element. If the element is not found, return -1. The function should be efficient and correctly handle edge cases such as an empty list or an element not present in the list. The code should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(arr: List[int], x: int) -> int: """ Perform a binary search on a sorted list to find the index of a given element. Args: arr (List[int]): A sorted list of integers. ...
evol_instruct_66k
22,290
Write a Python function to generate a random sequence of 5 distinct alphanumeric characters, ensuring that it starts with a letter and ends with a numeral, and no character is repeated. The function should return the generated sequence as a string. The code should start with: ```python import random import string def...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_random_sequence() -> str: """ Generates a random sequence of 5 distinct alphanumeric characters, ensuring that it starts with a letter and ends with a numeral, and no character is repeat...
evol_instruct_66k
22,292
Write a Python function to construct a dictionary from the given input arrays of keys and values, and then sort the dictionary by the length of the values in descending order. The function should return the sorted dictionary. The code should start with: ```python from typing import List, Dict def sort_dict_by_value_le...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_dict_by_value_length(key_arr: List[int], value_arr: List[str]) -> Dict[int, str]: """ Constructs a dictionary from the given keys and values, and sorts the dictionary by the length of the ...
evol_instruct_66k
22,294
Write a Python function to create a dictionary from two lists, one containing keys and the other containing values. If the lists are of different lengths, the function should handle this by only creating key-value pairs for the elements that have corresponding pairs in both lists. The function should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_dict_from_lists(keys: List[int], values: List[str]) -> Dict[int, str]: """ Creates a dictionary from two lists, one containing keys and the other containing values. If the lists are ...
evol_instruct_66k
22,310
Write a Python function to calculate and return the total and average marks for each student in a given dictionary. The dictionary contains students' names as keys and lists of marks from five different subjects as values. Each subject is scored out of 100. The function should return a new dictionary with the students'...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def calculate_marks(students: Dict[str, List[int]]) -> Dict[str, Tuple[int, float]]: """ Calculate the total and average marks for each student in the given dictionary. Args: st...
evol_instruct_66k
22,313
Write a Python function to determine the divisibility quotient of a given number by 5. The function should return the quotient when the number is divided by 5. The function should handle both positive and negative integers, as well as zero. The code should start with: ```python def divisibility_quotient(num: int) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python def divisibility_quotient(num: int) -> int: """ Calculate the divisibility quotient of a given number by 5. Args: num (int): The number for which to calculate the divisibility quotient. Returns: int: Th...
evol_instruct_66k
22,316
Write a Python function to implement the linear search algorithm, which searches for a target element in a given list and returns the index of the element if found, otherwise returns -1. The function should be efficient and handle edge cases such as an empty list or the target element not being present in the list. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def linear_search(arr: List[int], target: int) -> int: """ Perform a linear search to find the index of the target element in the given list. Args: arr (List[int]): The list of integers to s...
evol_instruct_66k
22,322
Write a Python function to generate the first `n` prime numbers. The function should return a list of the first `n` prime numbers. The code should start with: ```python from typing import List def generate_first_n_primes(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_first_n_primes(n: int) -> List[int]: """ Generate the first n prime numbers. Args: n (int): The number of prime numbers to generate. Returns: List[int]: A list cont...
evol_instruct_66k
22,328
Write a Python function to generate an array of random integers within a specific range and of a specified length. The function should ensure that the generated integers fall within the given range and the array has the specified length. The code should start with: ```python from typing import List import random def g...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import random def generate_random_array(min_value: int, max_value: int, length: int) -> List[int]: """ Generates an array of random integers within a specified range and of a specified length. Arg...
evol_instruct_66k
22,352
Write a Python function to generate a 4-dimensional array filled with random numbers within a specified range. The function should allow specifying the dimensions of the array and the range of the random numbers. The code should start with: ```python import numpy as np def generate_random_4d_array(dimensions: tuple, ...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def generate_random_4d_array(dimensions: tuple, lower_bound: float, upper_bound: float) -> np.ndarray: """ Generate a 4-dimensional array filled with random numbers within a specified range. Args: ...
evol_instruct_66k
22,358
Write a Python function to determine if a given number is an Armstrong number. An Armstrong number (also known as a narcissistic number) is a number that is the sum of its own digits each raised to the power of the number of digits. The code should start with: ```python def is_armstrong_number(n: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_armstrong_number(n: int) -> bool: """ Determines if a given number is an Armstrong number. An Armstrong number (or narcissistic number) is a number that is the sum of its own digits each raised to the power of th...
evol_instruct_66k
22,368
Write a Python function to generate an hourglass shape using asterisks (`*`). The hourglass shape consists of a pyramid followed by an inverted pyramid, both aligned such that the base of the pyramid and the apex of the inverted pyramid are perfectly aligned. The function should take an integer `rows` as input, which r...
Here is the Python code to solve the given problem in the markdown block: ```python def print_hourglass(rows: int): """ Prints an hourglass shape using asterisks. The hourglass shape consists of a pyramid followed by an inverted pyramid, both aligned such that the base of the pyramid and the apex of th...
evol_instruct_66k
22,369
Write a Python function to generate a list of all lowercase letters in the English alphabet. The function should return a list containing each letter exactly once, in alphabetical order. The code should start with: ```python from typing import List def generate_lowercase_alphabet() -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def generate_lowercase_alphabet() -> List[str]: """ Generates a list of all lowercase letters in the English alphabet. Returns: List[str]: A list containing all 26 lowercase letters in alp...
evol_instruct_66k
22,375
Write a Python function to compute the number of synonyms for each entry in a given lexicon. The lexicon is represented as a dictionary where each key is a word and the corresponding value is a list of its synonyms. The function should return a new dictionary where each key is a word from the original lexicon, and the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def compute_synonyms(lexicon: Dict[str, List[str]]) -> Dict[str, int]: """ Computes the number of synonyms for each word in the given lexicon. Args: lexicon (Dict[str, List[str]]): A d...
evol_instruct_66k
22,377
Write a Python function to create a 3-dimensional NumPy array with all elements set to 0, and implement a function that traverses the array and counts the number of zero elements using only basic loop structures and conditionals. No use of NumPy's in-built functions for counting is allowed. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_3d_array(shape: tuple) -> np.ndarray: """ Create a 3-dimensional NumPy array with all elements set to 0. Args: shape (tuple): The shape of the 3D array. Returns: np.ndarra...
evol_instruct_66k
22,391
Write a Python function to count the number of substrings that can be formed from a given string. The function should return the total number of possible substrings, including both contiguous and non-contiguous substrings. The code should start with: ```python def count_substrings(string: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_substrings(string: str) -> int: """ Calculate the total number of substrings that can be formed from the given string. Args: string (str): The input string from which substrings are to be counted. Ret...
evol_instruct_66k
22,406
Write a Python function to find the greatest common divisor (GCD) of two given integers using the Euclidean algorithm. The function should handle both positive and negative integers. The code should start with: ```python def gcd(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def gcd(a: int, b: int) -> int: """ Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm. Args: a (int): The first integer. b (int): The second integer. Returns: ...
evol_instruct_66k
22,409
Write a Python function to convert a given time from a 24-hour format to a 12-hour format with AM/PM indication. The function should handle edge cases such as midnight (00:00) and noon (12:00) correctly. The code should start with: ```python def convert_24_to_12_hour_format(time24: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def convert_24_to_12_hour_format(time24: str) -> str: """ Converts a given time from a 24-hour format to a 12-hour format with AM/PM indication. Args: time24 (str): The time in 24-hour format (e.g., "22:00"). R...
evol_instruct_66k
22,414
Write a Python function to determine if two given dictionaries are identical in terms of their key-value pairs, regardless of the order of keys. The function should return `True` if the dictionaries are identical and `False` otherwise. The code should start with: ```python from typing import Dict def are_dicts_identic...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import Dict def are_dicts_identical(dict1: Dict, dict2: Dict) -> bool: """ Determines if two dictionaries are identical in terms of their key-value pairs, regardless of the order of keys. Args: dict1 ...
evol_instruct_66k
22,423
Write a Python function to find the smallest element in an unsorted list of integers efficiently. The function should handle edge cases such as an empty list and a list with a single element. The code should start with: ```python from typing import List def find_smallest_element(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_smallest_element(arr: List[int]) -> int: """ Finds the smallest element in an unsorted list of integers. Args: arr (List[int]): The list of integers from which to find the smalles...
evol_instruct_66k
22,425
Write a Python function to implement a binary search algorithm that finds the index of a given integer in a sorted list. If the integer is not found in the list, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list that does not contain the item. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def binary_search(sorted_list: List[int], item: int) -> Optional[int]: """ Perform a binary search to find the index of a given integer in a sorted list. Args: sorted_list (List[in...
evol_instruct_66k
22,435
Write a Python function to create a 2D NumPy array of size 4x3 filled with zeros without using `np.zeros()`. Additionally, write another function that checks if all elements in a given 2D array are zeros by manually iterating through each element. The code should start with: ```python import numpy as np def create_zer...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_zero_array() -> np.ndarray: """ Create a 4x3 NumPy array filled with zeros without using np.zeros(). Returns: np.ndarray: A 4x3 array filled with zeros. """ # Create a list of ...
evol_instruct_66k
22,437
Write a Python function to combine the elements of multiple dictionaries into a single dictionary without any duplicate keys. If there are duplicate keys, increment the value by 1. The function should start with: ```python from typing import List, Dict def combine_dicts(dicts: List[Dict[str, int]]) -> Dict[str, int]: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def combine_dicts(dicts: List[Dict[str, int]]) -> Dict[str, int]: """ Combines the elements of multiple dictionaries into a single dictionary. If there are duplicate keys, the value is incremen...
evol_instruct_66k
22,465
Write a Python function to find the minimum value from a list of floating-point numbers with numerous decimals. The function should handle lists of varying sizes, including empty lists, and return `None` if the list is empty. The function should be efficient and handle floating-point numbers within the range of -50 to ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_min_decimal(decimal_list: List[float]) -> Optional[float]: """ Find the minimum value from a list of floating-point numbers. Args: decimal_list (List[float]): A list of fl...
evol_instruct_66k
22,471
Write a Python function to compute the total count of elements in a given list. The function should take a list of integers as input and return the total number of elements in the list. The code should start with: ```python from typing import List def count_elements(lst: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_elements(lst: List[int]) -> int: """ Computes the total count of elements in a given list. Args: lst (List[int]): The list of integers whose elements are to be counted. Return...
evol_instruct_66k
22,474
Write a Python function to transform a given string such that the first letter of the string is converted to uppercase and all subsequent letters are converted to lowercase. The function should handle strings of any length, including empty strings. The code should start with: ```python def transform_string(input_string...
Here is the Python code to solve the given problem in the markdown block: : ```python def transform_string(input_string: str) -> str: """ Transforms the given string such that the first letter is uppercase and all subsequent letters are lowercase. Args: input_string (str): The string to be transfor...
evol_instruct_66k
22,481
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The function should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid. Args: m (int): The number of row...
evol_instruct_66k
22,485
Write a Python function to print the string "Hello Universe" in a colorful terminal output. Each word in the string should be displayed in a different color. The colors should be chosen from a predefined set of colors. The function should handle the case where the number of words exceeds the number of predefined colors...
Here is the Python code to solve the given problem in the markdown block: ```python def print_colorful_hello_universe(): """ Prints the string "Hello Universe" in a colorful terminal output. Each word in the string is displayed in a different color from a predefined set of colors. If the number of words...
evol_instruct_66k
22,498
Write a Python function to manage a data storage framework that encapsulates unique records for each client. Each record should include the client's proprietary name, topographic coordinates, and contact information. The function should allow adding new records, retrieving existing records, and listing all records. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def add_record(data_framework: Dict[str, Dict[str, Any]], proprietary_name: str, topographic_coordinates: str, contact: str) -> None: """ Add a new client record to the data framework. Args: ...
evol_instruct_66k
22,501
Write a Python function to collect all the unique alphabets from a given string, ignoring case sensitivity. The function should handle punctuation and whitespace, and return the unique alphabets in sorted order. The code should start with: ```python from typing import List def collect_unique_alphabets(s: str) -> List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def collect_unique_alphabets(s: str) -> List[str]: """ Collects all unique alphabets from a given string, ignoring case sensitivity, and returns them in sorted order. Args: s (str): The ...
evol_instruct_66k
22,505
Write a Python function to determine all unique numerical elements within two alphanumeric strings. The function should return a sorted list of unique numerical elements found in both strings. The code should start with: ```python from typing import List def extract_unique_numerical_elements(string1: str, string2: st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def extract_unique_numerical_elements(string1: str, string2: str) -> List[str]: """ Extracts and returns a sorted list of unique numerical elements from two alphanumeric strings. Args: strin...
evol_instruct_66k
22,509
Write a Python function to sort an array of fractional numbers in ascending order without using any in-built sorting functions. The function should implement the Bubble Sort algorithm. The code should start with: ```python from typing import List def sort_fractional_numbers(nums: List[float]) -> List[float]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_fractional_numbers(nums: List[float]) -> List[float]: """ Sorts an array of fractional numbers in ascending order using the Bubble Sort algorithm. Args: nums (List[float]): The arra...