source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
2,261
Write a Python function to construct an HTML table that illustrates the arrays of academic scores and corresponding subjects pertaining to a group of students. The table should present the scores of each student across multiple subjects and calculate the average score per student. It should also identify the highest an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def generate_html_table(student_marks: List[Dict[str, Union[int, None]]]) -> str: """ Generates an HTML table that illustrates the academic scores of students across multiple subjects. T...
evol_instruct_66k
2,269
Write a Python function to create a 3D array with three matrices, each having three rows and two columns, and assign unique values to each element. After creating the array, write a function that calculates the sum of each matrix and returns the maximum sum. The code should start with: ```python import numpy as np de...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_3d_array() -> np.ndarray: """ Create a 3D array with three 3x2 matrices, each element having a unique value. Returns: np.ndarray: A 3D array with three 3x2 matrices. """ # Init...
evol_instruct_66k
2,271
Write a Python function to reverse a given tuple and ensure that the tuple contains elements of different data types. The function should return the reversed tuple. The code should start with: ```python from typing import Tuple, Any def reverse_tuple(t: Tuple[Any, ...]) -> Tuple[Any, ...]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Any # Assign a tuple to variable y with elements of different data types y = (1, "two", 3.0, False) def reverse_tuple(t: Tuple[Any, ...]) -> Tuple[Any, ...]: """ Reverse the given tuple and return the...
evol_instruct_66k
2,272
Write a Python function to calculate the average and the sum of a list of numbers. The function should return both the average and the sum as a tuple. The code should start with: ```python from typing import List, Tuple def calculate_average_and_sum(numbers: List[int]) -> Tuple[float, int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Tuple def calculate_average_and_sum(numbers: List[int]) -> Tuple[float, int]: """ Calculate the average and the sum of a list of numbers. Args: numbers (List[int]): A list of integers for...
evol_instruct_66k
2,276
Write a Python function to categorize learners into relevant courses based on their field of study. The function should take a list of dictionaries, where each dictionary represents a student with keys `"name"` and `"major"`. The function should return a dictionary where the keys are the course names (i.e., the majors)...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def categorize_learners(student_list: List[Dict[str, str]]) -> Dict[str, List[str]]: """ Categorizes learners into relevant courses based on their field of study. Args: student_list (L...
evol_instruct_66k
2,277
Write a Python function to calculate the nth Fibonacci number using an iterative approach. The function should return the nth Fibonacci number, where the Fibonacci sequence starts with 0 and 1. The code should start with: ```python def fibonacci(n: int) -> int: ```
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 an iterative approach. Args: n (int): The position in the Fibonacci sequence to calculate. Returns: int: The nth Fibonacci numb...
evol_instruct_66k
2,290
Write a Python function to shuffle the elements of a given tuple of strings and return a new shuffled tuple. Additionally, create a function that calculates and returns the frequencies of characters in the tuple before and after the shuffle. The original tuple should remain unchanged due to the immutability of tuples. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Counter import random from collections import Counter def shuffle_tuple(strings: Tuple[str]) -> Tuple[str]: """ Shuffle the elements of a given tuple of strings and return a new shuffled tuple. Ar...
evol_instruct_66k
2,298
Write a Python function to count the frequency of each distinct element in a given numerical array. The function should return a dictionary where the keys are the distinct elements and the values are their respective counts. The code should start with: ```python from typing import List, Dict def count_frequencies(num...
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 count_frequencies(numerical_array: List[int]) -> Dict[int, int]: """ Counts the frequency of each distinct element in the given numerical array. Args: ...
evol_instruct_66k
2,303
Write a Python function to calculate and return a list of the cubes of numbers from 1 to n, where n is a positive integer provided as an argument. The function should handle the case where n is less than 1 by returning an empty list. The code should start with: ```python from typing import List def calculate_cubes(n:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_cubes(n: int) -> List[int]: """ Calculate and return a list of the cubes of numbers from 1 to n. Args: n (int): The upper limit of the range (inclusive) for which to calculate ...
evol_instruct_66k
2,304
Write a Python function to perform a ternary search on a sorted 1-dimensional array of integers to find the index of a given element. If the element is not found, return -1. The function should be efficient and leverage the properties of a ternary search algorithm. 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 ternary_search(arr: List[int], x: int) -> int: """ Perform a ternary search on a sorted 1-dimensional array to find the index of a given element. Args: arr (List[int]): A sorted list of ...
evol_instruct_66k
2,314
Write a Python function to calculate the aggregated sum of the "price" values across a list of dictionaries and return it as an integer value. Each dictionary in the list contains a single key "price" with an integer value. The function should handle cases where the list is empty or contains dictionaries without the "p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def aggregate_prices(list_of_dictionaries: List[Dict[str, int]]) -> int: """ Calculate the aggregated sum of the "price" values across a list of dictionaries. Args: list_of_dictionarie...
evol_instruct_66k
2,315
Write a Python function to generate a unique non-repeating sequence of a specified length, containing characters from the set of alphabets (excluding 'x', 'y', 'z'), digits, and special characters. The sequence must not contain three consecutive similar characters. The function should start with: ```python import rando...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_unique_sequence(length: int) -> str: """ Generates a unique non-repeating sequence of the specified length, containing characters from the set of alphabets (excluding 'x', 'y', 'z'), dig...
evol_instruct_66k
2,328
Write a Python function to find the index of the solitary numeric element in a given list of integers. A solitary numeric element is defined as an element that appears exactly once in the list. If no such element exists, the function should return -1. The function should be efficient and avoid using the `count` method ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_solitary_index(arr: List[int]) -> int: """ Find the index of the solitary numeric element in a given list of integers. A solitary numeric element is defined as an element that appears exact...
evol_instruct_66k
2,333
Write a Python function to reverse a string without using any built-in functions or methods. The function should iterate through the string and construct the reversed string manually. The code should start with: ```python def reverse_string(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(s: str) -> str: """ Reverses the input string without using any built-in functions or methods. Args: s (str): The input string to be reversed. Returns: str: The reversed string. "...
evol_instruct_66k
2,334
Write a Python function to identify the penultimate lowest and penultimate highest numbers from a given numerical array. The function should return a tuple containing these two values. The code should start with: ```python from typing import List, Tuple def find_penultimate_numbers(array: List[int]) -> Tuple[int, int]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_penultimate_numbers(array: List[int]) -> Tuple[int, int]: """ Identify the penultimate lowest and penultimate highest numbers from a given numerical array. Args: array (List[...
evol_instruct_66k
2,337
Write a Python function to transform an array of integers, each ranging from 0 to 255, into a coherent string representation. The function should handle arrays of any length, not just a dozen integers. The code should start with: ```python from typing import List def array_to_string(array: List[int]) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def array_to_string(array: List[int]) -> str: """ Transforms an array of integers, each ranging from 0 to 255, into a coherent string representation. Args: array (List[int]): The array of in...
evol_instruct_66k
2,347
Write a Python function to generate a greeting string that combines the word "Hola" with the reverse of a given input string. The function should handle any input string and return the combined string. The code should start with: ```python def generate_greeting(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def generate_greeting(input_string: str) -> str: """ Generates a greeting string by combining "Hola" with the reverse of the input string. Args: input_string (str): The input string to be reversed and combined with ...
evol_instruct_66k
2,386
Write a Python function to calculate the average of a list of numbers, ensuring that the function uses type hinting for all parameters and return values. The function should handle lists containing integers and floats. The code should start with: ```python from typing import List, Union def calculate_average(numbers: ...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Union def calculate_average(numbers: List[Union[int, float]]) -> Union[int, float]: """ Calculate the average of a list of numbers. Args: numbers (List[Union[int, float]]): A list of inte...
evol_instruct_66k
2,388
Write a Python function to sort a given sequence of floating-point numbers in descending order. The function should take a list of floating-point numbers as input and return a new list with the numbers sorted in descending order. The original list should not be modified. 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 sort_descending(seq: List[float]) -> List[float]: """ Sorts a given sequence of floating-point numbers in descending order and returns the sorted list. Args: seq (List[float]): The list ...
evol_instruct_66k
2,390
Write a Python function to compute the product of all elements in a given list of integers. The function should handle lists of any length, including empty lists. The code should start with: ```python from typing import List def product_of_elements(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def product_of_elements(arr: List[int]) -> int: """ Compute the product of all elements in a given list of integers. Args: arr (List[int]): The list of integers whose product is to be comp...
evol_instruct_66k
2,392
Write a Python function to create a dictionary with three unique key-value pairs, where each key is a string and each value is an integer. The keys should be in lexicographical order, and the values should be in ascending order. The function should return the dictionary. 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 Dict def create_ordered_dict() -> Dict[str, int]: """ Creates a dictionary with three unique key-value pairs. The keys are strings in lexicographical order, and the values are integers in ascending order....
evol_instruct_66k
2,398
Write a Python function that calculates the sum of the digits of a non-negative integer. The function should also handle two optional arguments: 1. If the first optional argument is provided, the function should return the sum of the digits raised to the power of this argument. 2. If the second optional argument is pro...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_digits(num: int, pow_val: int = None, mod_val: int = None) -> int or str: """ Calculate the sum of the digits of a non-negative integer. Optionally, raise the sum to a power and/or apply a modulo operation. Args:...
evol_instruct_66k
2,425
Write a Python function to calculate the power of a number \( x \) raised to \( y \) without using the built-in power function. Implement error handling for cases where \( y \) is negative and \( x \) equals 0. The function should handle both positive and negative values of \( y \). The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def custom_power(x: float, y: int) -> float: """ Calculate the power of a number x raised to y without using the built-in power function. Args: x (float): The base number. y (int): The exponent. Returns...
evol_instruct_66k
2,428
Write a Python function to count the number of vowels in a given string, considering both uppercase and lowercase vowels, and excluding numbers and special characters. The function should be case-insensitive and should only count the vowels 'a', 'e', 'i', 'o', 'u'. The code should start with: ```python def count_vowel...
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 the given string, considering both uppercase and lowercase vowels. Args: s (str): The input string to count vowels from. Returns: int:...
evol_instruct_66k
2,431
Write a Python function to generate the first `n` members of the Fibonacci sequence. The Fibonacci sequence is a numerical series where each digit is the sum of the preceding two. The function should return a list containing the first `n` Fibonacci numbers. 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 generate_fibonacci(n: int) -> List[int]: """ Generate the first n members of the Fibonacci sequence. The Fibonacci sequence is a numerical series where each digit is the sum of the preceding two...
evol_instruct_66k
2,448
Write a Python function to create and return a dictionary containing key-value associations for specific fruit types and their corresponding amounts. The function should accept a list of tuples, where each tuple contains a fruit name and its corresponding amount. The function should return a dictionary with the fruit n...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_fruit_dictionary(fruit_list: List[Tuple[str, int]]) -> Dict[str, int]: """ Creates a dictionary from a list of tuples, where each tuple contains a fruit name and its corresponding...
evol_instruct_66k
2,469
Implement a Python function to sort a list of floating-point numbers using the Bucket Sort algorithm. The function should efficiently distribute the numbers into buckets based on their decimal values and then sort each bucket individually before concatenating them back into a single sorted list. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bucket_sort(arr: List[float]) -> List[float]: """ Sorts a list of floating-point numbers using the Bucket Sort algorithm. Args: arr (List[float]): The list of floating-point numbers to b...
evol_instruct_66k
2,471
Write a Python function to find the sum of two digits. The function should handle invalid inputs such as `None`, negative numbers, and decimal numbers by returning a customizable error message. The function should also ensure that the inputs are within the range of 0 to 9. The code should start with: ```python def sum...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_digits(a: int, b: int, type_error_msg: str = "Input must be a positive integer or zero.", null_error_msg: str = "Input must not be null.") -> str: """ Calculate the sum of two digits and handle invalid inputs with cus...
evol_instruct_66k
2,474
Write a Python function to calculate the cube of each value in a given dictionary and return a new dictionary with the same keys but with the values replaced by their cubes. The function should handle dictionaries with integer values only. The code should start with: ```python from typing import Dict def cube_values_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def cube_values_in_dict(input_dict: Dict[str, int]) -> Dict[str, int]: """ Calculate the cube of each value in the given dictionary and return a new dictionary with the same keys but with the values ...
evol_instruct_66k
2,483
Write a Python function to generate a random string of a specified length. The string should consist of alphanumeric characters (both uppercase and lowercase letters, and digits). The function should ensure that the generated string is at least 10 characters long. If the specified length is less than 10, the function s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random import string def generate_random_string(length: int) -> str: """ Generates a random string of the specified length, consisting of alphanumeric characters. If the specified length is le...
evol_instruct_66k
2,487
Write a Python function to determine the number of unique paths in a grid from the top-left corner to the bottom-right corner, where you can only move right or down. The grid is represented by a 2D list of integers, where 0 indicates a free cell and 1 indicates an obstacle. The function should return the number of uniq...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def unique_paths_with_obstacles(grid: List[List[int]]) -> int: """ Calculate the number of unique paths from the top-left to the bottom-right corner in a grid with obstacles. Args: grid (Lis...
evol_instruct_66k
2,488
Write a Python function that takes two numerical lists as input and returns a new list that combines the squared values from the first list with the odd values from the second list. If either of the inputs is not a list or contains non-numerical data, the function should raise a `ValueError`. 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 consolidate_lists(list1: List[float], list2: List[float]) -> List[float]: """ Consolidates two numerical lists by combining the squared values from the first list with the odd values from the sec...
evol_instruct_66k
2,512
Write a Python function to perform a binary search on a sorted array to find the index of a specific element. If the element is not found, return -1. The function should handle edge cases such as an empty array or an element not present in the array. The code should start with: ```python from typing import List def bi...
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 array to find the index of a specific element. Args: arr (List[int]): A sorted list of integers. ...
evol_instruct_66k
2,516
Write a Python function to perform a bubble sort algorithm on a given list of non-negative integers, arranging the elements in descending order. The function should return the sorted list. The code should start with: ```python from typing import List def bubble_sort_descending(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 bubble_sort_descending(arr: List[int]) -> List[int]: """ Sorts a list of non-negative integers in descending order using the bubble sort algorithm. Args: arr (List[int]): The list of non...
evol_instruct_66k
2,517
Write a Python function to filter out even numbers from a given list of integers. The function should return a new list containing only the even numbers from the input list. The code should start with: ```python from typing import List def filter_even_numbers(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 filter_even_numbers(numbers: List[int]) -> List[int]: """ Filters out even numbers from a given list of integers. Args: numbers (List[int]): A list of integers from which to filter even ...
evol_instruct_66k
2,520
Write a Python function to validate if a given string consists solely of uppercase English alphabets and numerical digits using a regular expression. The function should return `True` if the string matches the pattern and `False` otherwise. The code should start with: ```python import re def is_valid_string(s: str) ->...
Here is the Python code to solve the given problem in the markdown block: ```python import re def is_valid_string(s: str) -> bool: """ Validates if the given string consists solely of uppercase English alphabets and numerical digits. Args: s (str): The string to be validated. Returns: ...
evol_instruct_66k
2,522
Write a Python function to find the k-th smallest number in a given list of integers. The function should be efficient and handle lists of varying lengths. The code should start with: ```python from typing import List def find_kth_smallest(nums: List[int], k: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_kth_smallest(nums: List[int], k: int) -> int: """ Find the k-th smallest number in a given list of integers. Args: nums (List[int]): The list of integers from which to find the k-...
evol_instruct_66k
2,531
Write a Python function to construct a list of automobile models, ensuring the inclusion of specific models "Honda Accord", "Toyota Corolla", and "Ford F150", and allowing for the addition of more models. The function should return the final list of automobile models. The code should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def construct_automobile_list() -> List[str]: """ Constructs a list of automobile models, ensuring the inclusion of "Honda Accord", "Toyota Corolla", and "Ford F150", and optionally adding more model...
evol_instruct_66k
2,553
Write a Python function to find the five least common elements from a given list of integers. If the list has fewer than five unique elements, return all unique elements sorted by their frequency in ascending order. The function should handle lists with any number of elements, including empty lists. The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import Counter def find_five_least_common(lst: List[int]) -> List[int]: """ Returns the five least common elements from the given list of integers. Args: lst (List[int]): Th...
evol_instruct_66k
2,558
Write a Python function to convert a given time in the 24-hour format to its equivalent in the 12-hour format. The input time is a string in the format "HH:MM". The function should return a string in the format "HH:MM AM/PM". The code should start with: ```python from datetime import datetime def convert_24_to_12_hou...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def convert_24_to_12_hour_format(time_str: str) -> str: """ Converts a given time in the 24-hour format to its equivalent in the 12-hour format. Args: time_str (str): The time in the 2...
evol_instruct_66k
2,580
Write a Python function to remove all occurrences of specific characters from a given string. These characters include spaces, special characters, and numbers. Maintain the order of the remaining string characters intact. The function should start with: ```python def remove_specific_chars(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def remove_specific_chars(s: str) -> str: """ Removes all occurrences of spaces, special characters, and numbers from the given string. Maintains the order of the remaining alphabetic characters. Args: s (str): ...
evol_instruct_66k
2,596
Write a Python function to analyze a given matrix and return the number of rows, the number of columns, the sum of the diagonal elements, and a boolean indicating whether the matrix is square. The function should correctly handle matrices of any size, including empty matrices. 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 List, Tuple def analyze_matrix(matrix: List[List[int]]) -> Tuple[int, int, int, bool]: """ Analyzes a given matrix and returns the number of rows, the number of columns, the sum of the diagonal elements, ...
evol_instruct_66k
2,599
Write a Python function to replace all instances of dual spaces with single spaces in a given text string. The function should be efficient and handle various edge cases, such as multiple consecutive dual spaces, leading and trailing spaces, and spaces within words. The code should start with: ```python def replace_du...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_dual_spaces(text: str) -> str: """ Replace all instances of dual spaces with single spaces in the given text string. Args: text (str): The input text string where dual spaces need to be replaced. Re...
evol_instruct_66k
2,607
Write a Python function to remove successive identical elements from a given list and return the count of these removed duplicates. The function should handle lists of varying data types. The code should start with: ```python from typing import List, Tuple, Any def remove_successive_duplicates_with_count(lst: List[Any...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any def remove_successive_duplicates_with_count(lst: List[Any]) -> Tuple[List[Any], int]: """ Removes successive identical elements from the given list and returns the count of these removed dupl...
evol_instruct_66k
2,630
Write a Python function to create a user profile dictionary with the keys "name", "age", and "location". The function should validate the input types and raise appropriate exceptions if the inputs are invalid. The function should start with: ```python from typing import Dict def create_user_profile(name: str, age: int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def create_user_profile(name: str, age: int, location: str) -> Dict[str, str | int]: """ Create a user profile dictionary with keys "name", "age", and "location". Args: name (str): The name ...
evol_instruct_66k
2,632
Write a Python function to organize an array of real, non-integer numbers in a sequential pattern. The function should take into account both positive and negative values and allow for both ascending and descending order. The function should start with: ```python from typing import List def organize_numbers(numbers: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def organize_numbers(numbers: List[float], ascending: bool = True) -> List[float]: """ Organizes an array of real, non-integer numbers in a sequential pattern. Args: numbers (List[float]): T...
evol_instruct_66k
2,636
Write a Python function to concatenate an array of lexical items according to a specified format string. The format string contains placeholders that the function will replace with elements from the array. If the number of placeholders exceeds the number of elements in the array, the remaining placeholders should be fi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def format_lexical_items(arr: List[str], format_string: str, default_string: str = "nothing") -> str: """ Concatenates an array of lexical items according to a specified format string. If the number ...
evol_instruct_66k
2,674
Write a Python function to rearrange the elements of a given tuple in descending order. The function should return a new tuple with the elements sorted in descending order. The original tuple should not be modified. The code should start with: ```python from typing import Tuple def sort_tuple_descending(input_tuple: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def sort_tuple_descending(input_tuple: Tuple[int]) -> Tuple[int]: """ Sorts the elements of a given tuple in descending order and returns a new tuple. Args: input_tuple (Tuple[int]): The tu...
evol_instruct_66k
2,678
Write a Python function to concatenate two strings with an optional separator. The function should allow specifying a separator string that will be placed between the two input strings during concatenation. If no separator is provided, the function should concatenate the strings without any separator. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_strings(str1: str, str2: str, separator: str = '') -> str: """ Concatenates two strings with an optional separator. Args: str1 (str): The first string to concatenate. str2 (str): The second s...
evol_instruct_66k
2,680
Write a Python function to isolate elements from a dictionary whose keys start with a specified alphabetical symbol. The function should return a new dictionary containing only the key-value pairs that match the criteria. The code should start with: ```python from typing import Dict def isolate_dict_elements(d: Dict[s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def isolate_dict_elements(d: Dict[str, int], symbol: str) -> Dict[str, int]: """ Isolate elements from a dictionary whose keys start with a specified alphabetical symbol. Args: d (Dict[str, ...
evol_instruct_66k
2,692
Write a Python function to insert an element into a sorted list at a specified index while maintaining the sorted order of the list. If the specified index is out of bounds, the element should be inserted at the nearest valid position to maintain the sorted order. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insert_into_sorted_list(sorted_list: List[int], element: int, index: int) -> List[int]: """ Inserts an element into a sorted list at a specified index while maintaining the sorted order. Args: ...
evol_instruct_66k
2,695
Write a Python function to find the longest continuously increasing subsequence (LCIS) in a given list of integers. The function should return the subsequence as a list. The subsequence must be strictly increasing and must be the longest possible. The code should start with: ```python from typing import List def long...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def longest_increasing_subsequence(my_list: List[int]) -> List[int]: """ Finds the longest continuously increasing subsequence in a given list of integers. Args: my_list (List[int]): The lis...
evol_instruct_66k
2,698
Write a Python function to sort a list of prime numbers in monotonically decreasing order. The function should take a list of integers as input and return a new list with the same integers sorted in descending order. The original list should not be modified. 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 def sort_primes_descending(primes: List[int]) -> List[int]: """ Sorts a list of prime numbers in monotonically decreasing order. Args: primes (List[int]): A list of prime numbers. Retur...
evol_instruct_66k
2,708
Write a Python function to remove all occurrences of a specified entity from a given list of strings. The function should iterate through the list and remove every instance of the specified entity. The function should return the modified list. The code should start with: ```python from typing import List def remove_e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_entity(fruits: List[str], entity: str) -> List[str]: """ Removes all occurrences of a specified entity from a given list of strings. Args: fruits (List[str]): The list of strings ...
evol_instruct_66k
2,711
Write a Python function to generate a list of random integers within a specified range and of a specified length. The function should ensure that the generated list contains unique integers (no duplicates) and should handle edge cases such as invalid input parameters. The code should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_unique_random_integers(length: int, lower_bound: int, upper_bound: int) -> List[int]: """ Generates a list of unique random integers within a specified range and of a specified...
evol_instruct_66k
2,725
Write a Python function to dissect a given textual string into its individual lexical components (words) and return them as a list. The function should handle various delimiters such as spaces, commas, periods, and other punctuation marks. The function should also handle multiple consecutive delimiters by treating them...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def split_text_into_lexical_components(text: str) -> List[str]: """ Dissects a given textual string into its individual lexical components (words) and returns them as a list. Args: ...
evol_instruct_66k
2,726
Write a Python function to extract and return a list of road or avenue names from a given address string. The function should be able to recognize and extract common abbreviations and full names of roads and avenues. The code should start with: ```python import re from typing import List def extract_road_names(address...
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def extract_road_names(address: str) -> List[str]: """ Extracts and returns a list of road or avenue names from a given address string. Args: address (str): The address string from...
evol_instruct_66k
2,729
Write a Python function to calculate the Body Mass Index (BMI) for a person given their height in centimeters and weight in kilograms. The function should return the BMI rounded to two decimal places. The code should start with: ```python def calculate_bmi(height_cm: float, weight_kg: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_bmi(height_cm: float, weight_kg: float) -> float: """ Calculate the Body Mass Index (BMI) for a person given their height in centimeters and weight in kilograms. Args: height_cm (float): The height of ...
evol_instruct_66k
2,740
Write a Python function to generate a random alphanumeric string of a specified length, ensuring that the string contains at least one uppercase letter, one lowercase letter, and one digit. The function should start with: ```python from typing import List def generate_secure_random_string(length: int) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import random import string def generate_secure_random_string(length: int) -> str: """ Generates a random alphanumeric string of the specified length, ensuring it contains at least one uppercase letter...
evol_instruct_66k
2,750
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(list_items: 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(list_items: List[int]) -> List[int]: """ Sorts the given list of integers in descending order. Args: list_items (List[int]): The list of integers to be sorted. Retur...
evol_instruct_66k
2,756
Write a Python function to count the number of words in a given string, considering various edge cases such as multiple spaces, leading and trailing spaces, and punctuation. The function should handle these cases gracefully and return the correct count of individual words. The code should start with: ```python def cou...
Here is the Python code to solve the given problem in the markdown block: ```python def count_words(input_string: str) -> int: """ Counts the number of individual words in a given string. Args: input_string (str): The input string containing words to be counted. Returns: int: The numbe...
evol_instruct_66k
2,759
Write a Python function to merge two unsorted arrays into a sorted array without using any extra space. The function should ensure that it works in O(nlogn) time complexity. The code should start with: ```python from typing import List def sorted_merge(nums1: List[int], nums2: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sorted_merge(nums1: List[int], nums2: List[int]) -> List[int]: """ Merges two unsorted arrays into a single sorted array without using extra space. Args: nums1 (List[int]): The first uns...
evol_instruct_66k
2,762
Write a Python function to translate a given textual phrase into its binary equivalent. Each character in the phrase should be converted to its 8-bit binary representation, and the binary representations should be joined with spaces. The function should adhere to the following constraints: - The input text is a string....
Here is the Python code to solve the given problem in the markdown block: ```python def text_to_binary(text: str) -> str: """ Converts a given textual phrase into its binary equivalent. Each character in the input text is converted to its 8-bit binary representation, and the binary representations are ...
evol_instruct_66k
2,765
Write a Python function to generate and return all possible permutations of pairs from two given lists. Each pair should consist of one element from the first list and one element from the second list. The function should return a list of tuples, where each tuple represents a pair. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import itertools def generate_permutations(list1: List[int], list2: List[int]) -> List[Tuple[int, int]]: """ Generate all possible permutations of pairs from two given lists. Args: li...
evol_instruct_66k
2,768
Refactor the given code to improve its readability, efficiency, and adherence to best coding practices. Specifically, remove any redundant code, excessive white spaces, and unnecessary semi-colons. Ensure the function `calculate_absolute_difference` is concise and clear. The code should start with: ```python def calcu...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_absolute_difference(num1: int, num2: int) -> int: """ Calculate the absolute difference between two numbers. Args: num1 (int): The first number. num2 (int): The second number. Returns: ...
evol_instruct_66k
2,782
Write a Python function to insert a given item at a specified position in a list, including checks for invalid inputs and error handling. Additionally, implement support for inserting lists as items without merging them into the target list. Instead of using the built-in `insert()` method, write a custom function that ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def insert_item_at_position(arr: List[Any], item: Any, position: int) -> List[Any]: """ Inserts a given item at a specified position in a list, handling invalid inputs and supporting list items. ...
evol_instruct_66k
2,787
Write a Python function to remove duplicate strings from a given dataset of fruit nomenclature strings while preserving the order of their first appearance. The dataset is a list of strings. The code should start with: ```python from typing import List def remove_duplicates(dataset: 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_duplicates(dataset: List[str]) -> List[str]: """ Removes duplicate strings from the given dataset while preserving the order of their first appearance. Args: dataset (List[str]): ...
evol_instruct_66k
2,792
Write a Python function to find the largest number from a given list of integers and return both the largest number and its index(es). The function should handle negative numbers and duplicates correctly. The code should start with: ```python from typing import List, Tuple def find_largest_number_and_index(numbers: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_largest_number_and_index(numbers: List[int]) -> Tuple[int, List[int]]: """ Finds the largest number from a given list of integers and returns both the largest number and its index(es). ...
evol_instruct_66k
2,793
Write a Python function to convert a date string in the format 'DD MMM YYYY' (e.g., '01 Jan 2018') to a date string in the format 'DD-MM-YYYY'. The function should handle the conversion efficiently and ensure that the output date string strictly follows the 'DD-MM-YYYY' structure. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def convert_date_format(date_string: str) -> str: """ Converts a date string from 'DD MMM YYYY' format to 'DD-MM-YYYY' format. Args: date_string (str): The input date string in 'DD MMM...
evol_instruct_66k
2,797
Write a Python function to merge two tuples element-by-element alternately. If the tuples are of unequal lengths, the remaining elements of the longer tuple should be appended to the result. The function should start with: ```python from typing import Tuple def merge_tuples(tuple1: Tuple[any], tuple2: Tuple[any]) -> T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def merge_tuples(tuple1: Tuple[any], tuple2: Tuple[any]) -> Tuple[any]: """ Merges two tuples element-by-element alternately. If the tuples are of unequal lengths, the remaining elements of the long...
evol_instruct_66k
2,817
Write a Python function to find the intersection of two unsorted lists of positive integers without using built-in functions like `set` or `dict`. The function should optimize the algorithm for time complexity not exceeding O(n log n). The code should start with: ```python from typing import List def get_intersection(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_intersection(lst1: List[int], lst2: List[int]) -> List[int]: """ Find the intersection of two unsorted lists of positive integers without using built-in functions. Args: lst1 (List[i...
evol_instruct_66k
2,826
Write a Python function to reverse the characters in a given string using advanced string handling techniques. The function should return the reversed string. The code should start with: ```python def reverse_string(input_str: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(input_str: str) -> str: """ Reverses the characters in the given string. Args: input_str (str): The string to be reversed. Returns: str: The reversed string. """ # Use slicing...
evol_instruct_66k
2,832
Write a Python function to subtract two numbers and return the result. The function should take two integers as input and return their difference. The code should start with: ```python def subtract_numbers(num1: int, num2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def subtract_numbers(num1: int, num2: int) -> int: """ Subtracts the second number from the first number and returns the result. Args: num1 (int): The first number. num2 (int): The second number. Return...
evol_instruct_66k
2,841
Write a Python function to sort a list of numerical values in increasing order. The function should accept a list of integers or floats and return a new list with the elements sorted in ascending order. The original list should not be modified. The code should start with: ```python from typing import List def sort_lis...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sort_list(nums: List[float]) -> List[float]: """ Returns a new list with the elements of the input list sorted in increasing order. Args: nums (List[float]): The list of numerical valu...
evol_instruct_66k
2,843
Write a Python function to sort a dictionary by its values in ascending order. If two keys have the same value, their order should be preserved according to their original order in the dictionary. The function should return a new dictionary with the sorted key-value pairs. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dictionary_by_value(d: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary by its values in ascending order. If two keys have the same value, their order is preserved according to thei...
evol_instruct_66k
2,844
Write a Python function to generate a list of all prime numbers in a given range [start, end] using the Sieve of Eratosthenes algorithm. The function should return a list of prime numbers within the specified range. The code should start with: ```python from typing import List def generate_primes_in_range(start: int, ...
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 all prime numbers in the range [start, end] using the Sieve of Eratosthenes algorithm. Args: start (in...
evol_instruct_66k
2,851
Write a Python function that takes a list of discrete alphabetic characters and consolidates them into a single, uninterrupted text string. The function should be implemented using higher-order functions to enhance readability and maintainability. The code should start with: ```python from typing import List def conso...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def consolidate_characters(chars: List[str]) -> str: """ Consolidates a list of discrete alphabetic characters into a single, uninterrupted text string. Args: chars (List[str]): A list of di...
evol_instruct_66k
2,856
Write a Python function to generate a random string of a specified length made up of uppercase letters and digits. The function should allow the user to specify the length of the string, with a default length of 8. The code should start with: ```python import random import string def generate_random_string(length: int...
Here is the Python code to solve the given problem in the markdown block: : ```python import random import string def generate_random_string(length: int = 8) -> str: """ Generates a random string of the specified length made up of uppercase letters and digits. Args: length (int): The length of the...
evol_instruct_66k
2,865
Write a Python function to determine if two integer values are not equal without using any equality or inequality operators. The function should use bitwise operations to achieve this. The code should start with: ```python def are_not_equal(x: int, y: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def are_not_equal(x: int, y: int) -> bool: """ Determines if two integers are not equal using bitwise operations. Args: x (int): The first integer. y (int): The second integer. Returns: bool: Tr...
evol_instruct_66k
2,881
Write a Python function to initialize and return a list of `n` empty lists. The function should handle cases where `n` is zero or negative by returning an empty list. The code should start with: ```python from typing import List def create_n_empty_lists(n: int) -> List[List[None]]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_n_empty_lists(n: int) -> List[List[None]]: """ Initializes and returns a list containing `n` empty lists. Args: n (int): The number of empty lists to create. Returns: ...
evol_instruct_66k
2,883
Write a Python function to find the largest sum from any two distinct numbers in a given array of integers. The function should ensure that the two numbers chosen are distinct and the sum is the largest possible. The code should start with: ```python from typing import List def find_largest_sum_of_distinct_numbers(ar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_largest_sum_of_distinct_numbers(arr: List[int]) -> int: """ Find the largest sum from any two distinct numbers in the given array. Args: arr (List[int]): The array of integers from ...
evol_instruct_66k
2,887
Write a Python function to find the nth term in a series where each term is the sum of the two preceding even numbers in the series. The series starts with the first two even numbers, 0 and 2. The code should start with: ```python def find_nth_even_fibonacci(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_nth_even_fibonacci(n: int) -> int: """ Calculate the nth term in a series where each term is the sum of the two preceding even numbers. Args: n (int): The position of the term to find in the series. Re...
evol_instruct_66k
2,890
Write a Python function to generate a list of squares of numbers within a given range, inclusively. The function should take two integers, `start` and `end`, as input and return a list of tuples where each tuple contains a number and its square. The function should handle cases where `start` is greater than `end` by re...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_squares(start: int, end: int) -> List[Tuple[int, int]]: """ Generate a list of tuples where each tuple contains a number and its square within the given range, inclusively. Args:...
evol_instruct_66k
2,892
Write a Python function to filter and return the name of the mountain range and the peak that is the highest in the world from a given list of tuples. Each tuple contains the name of a mountain range and its highest peak height. The function should handle potential errors such as incorrect data types, missing data, and...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def get_highest_peak(data: List[Tuple[Union[str, int, float], Union[int, float]]]) -> Tuple[str, Union[int, float]]: """ Filters and returns the name of the mountain range and the peak that...
evol_instruct_66k
2,901
Write a Python function to generate a statistical dispersion table that illustrates the count or occurrence frequency of individual integers within a specified array of numeric integers. The function should return a dictionary where the keys are the unique integers from the input array and the values are their respecti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_dispersion_table(input_array: List[int]) -> Dict[int, int]: """ Generates a statistical dispersion table that illustrates the count or occurrence frequency of individual integers withi...
evol_instruct_66k
2,902
Write a Python function to find the smallest absolute value from a list of negative integers. The function should take a list of integers as input and return the smallest absolute value. The code should start with: ```python from typing import List def find_smallest_absolute_value(numbers: 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_absolute_value(numbers: List[int]) -> int: """ Find the smallest absolute value from a list of negative integers. Args: numbers (List[int]): A list of negative integers. ...
evol_instruct_66k
2,903
Write a Python function to generate the first n prime numbers. The function should return a list of these prime numbers. The code should start with: ```python from typing import List def generate_primes(n: 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 generate_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 lis...
evol_instruct_66k
2,916
Write a Python function to perform a cyclical permutation on a list by a given number of positions. The permutation can be either to the left or to the right, based on a specified direction. The function should handle cases where the number of positions is greater than the length of the list by taking the modulo of the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Literal def cyclical_permutation(my_list: List[int], positions: int, direction: Literal['left', 'right']) -> List[int]: """ Perform a cyclical permutation on a list by a given number of positions in the...
evol_instruct_66k
2,917
Write a Python function to randomize the order of elements in a given list. The function should return a new list with the same elements but in a randomized order. The original list should not be modified. The code should start with: ```python from typing import List import random def randomize_elements(input_list: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def randomize_elements(input_list: List[int]) -> List[int]: """ Randomizes the order of elements in a given list and returns a new list with the randomized elements. Args: inpu...
evol_instruct_66k
2,918
Write a Python function to calculate and trace the occurrence of all unique numbers in a given three-dimensional array. The function should return a dictionary where the keys are the unique numbers and the values are their respective counts. The code should start with: ```python from typing import List, Dict import nu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import numpy as np from collections import Counter def count_unique_numbers(data: np.ndarray) -> Dict[int, int]: """ Calculate and trace the occurrence of all unique numbers in a given three-dimens...
evol_instruct_66k
2,936
Write a Python function to calculate the sum of all elements in a list, which may contain nested lists. The function should handle any level of nested lists and accumulate their values correctly. The code should start with: ```python from typing import List, Union def nested_list_sum(num_list: Union[List[Union[int, L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def nested_list_sum(num_list: Union[List[Union[int, List]], int]) -> int: """ Calculate the sum of all elements in a list, which may contain nested lists. Args: num_list (Union[List[U...
evol_instruct_66k
2,938
Write a Python function to create a dictionary that maps each person's name to their corresponding birth date from two given lists: one containing names and the other containing birth dates. The function should ensure that the names and birth dates are correctly paired and that the resulting dictionary is returned. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_birth_date_map(names: List[str], birth_dates: List[str]) -> Dict[str, str]: """ Creates a dictionary that maps each person's name to their corresponding birth date. Args: na...
evol_instruct_66k
2,957
Write a Python function to determine the letter grade based on a numerical score using a switch-case construct. The function should map numerical scores to letter grades according to the following scale: - 90 and above: 'A' - 80 to 89: 'B' - 70 to 79: 'C' - 60 to 69: 'D' - Below 60: 'F' The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def get_grade(score: int) -> str: """ Determine the letter grade based on the numerical score. Args: score (int): The numerical score to be converted to a letter grade. Returns: str: The corresponding l...
evol_instruct_66k
2,958
Write a Python function to sort a list of student records based on their GPA (Grade Point Average) in descending order. Each student record is represented as a dictionary with keys 'name', 'gpa', and 'graduation_year'. The function should return a list of student records sorted by GPA. The code should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_students_by_gpa(students: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a list of student records by their GPA in descending order. Args: students (List[Dict[str, a...
evol_instruct_66k
2,969
Write a Python function to remove all special characters from a given string, leaving only alphanumeric characters and spaces. The function should handle strings of varying lengths and content, including strings with no special characters, strings with only special characters, and strings with a mix of alphanumeric cha...
Here is the Python code to solve the given problem in the markdown block: ```python import re def remove_special_characters(s: str) -> str: """ Removes all special characters from the given string, leaving only alphanumeric characters and spaces. Args: s (str): The input string from which special ...
evol_instruct_66k
2,970
Write a Python function to generate a random matrix of size `m x n` where each element is a floating-point number between 0 and 1. The function should return the generated matrix as a list of lists. The code should start with: ```python from typing import List import random def generate_random_matrix(m: int, n: int) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_random_matrix(m: int, n: int) -> List[List[float]]: """ Generate a random matrix of size m x n where each element is a floating-point number between 0 and 1. Args: ...
evol_instruct_66k
2,980
Write a Python function to count the frequency of a given numerical entity within a list. The function should take two parameters: a list of integers and an integer to count its occurrences in the list. The function should return the count as an integer. The code should start with: ```python from typing import List d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_frequency(arr: List[int], num: int) -> int: """ Counts the frequency of a given numerical entity within a list. Args: arr (List[int]): The list of integers in which to count the fr...
evol_instruct_66k
2,994
Write a Python function to calculate the product of two numbers. The function should take two integers as input and return their product. The code should start with: ```python def multiply(x: int, y: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def multiply(x: int, y: int) -> int: """ Calculate the product of two integers. Args: x (int): The first integer. y (int): The second integer. Returns: int: The product of the two integers. ...
evol_instruct_66k
3,028
Write a Python function to convert a given sentence into title case, where each word starts with an uppercase letter and all other letters are in lowercase. The function should handle various edge cases, such as handling punctuation, multiple spaces, and mixed case words. The code should start with: ```python def titl...
Here is the Python code to solve the given problem in the markdown block: ```python def title_case_sentence(sentence: str) -> str: """ Converts a given sentence into title case, where each word starts with an uppercase letter and all other letters are in lowercase. Args: sentence (str): The input s...
evol_instruct_66k
3,048
Write a Python function to generate an n x n identity matrix using the NumPy library. The identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere. The function should take an integer `n` as input and return the n x n identity matrix. The code should start with: ```python import numpy as n...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def generate_identity_matrix(n: int) -> np.ndarray: """ Generate an n x n identity matrix. Args: n (int): The size of the identity matrix. Returns: np.ndarray: An n x n identity matr...