source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 17,281 | Write a Python function to construct a valid SMTP email address from given segments: `local_part`, `domain`, and `sub_domain`. The function should ensure that the segments are properly combined to form a standard email address format. The code should start with:
```python
def construct_email(local_part: str, domain: st... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_email(local_part: str, domain: str, sub_domain: str) -> str:
"""
Constructs a valid SMTP email address from the given local-part, domain, and sub-domain.
Args:
local_part (str): The local part of the e... |
evol_instruct_66k | 17,304 | Write a Python function to sort a list of positive integers based on the length of their binary representation and their quotient when divided by a given divisor. If multiple integers have the same binary length, they should be sorted according to their quotient when divided by the divisor. The function should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_by_binary_len_and_divisor(arr: List[int], divisor: int) -> List[int]:
"""
Sorts a list of positive integers based on the length of their binary representation and their quotient when divided by ... |
evol_instruct_66k | 17,307 | Write a Python function to determine the amount invested in each of the four funds given the total investment amount, total dividends received after one year, and the dividend yields of the funds. The function should return the investment amounts for each of the four funds.
The code should start with:
```python
def ca... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_investments(total_investment: float, total_dividends: float, dividend_yield_fund1_fund2: float, dividend_yield_fund3_fund4: float) -> tuple:
"""
Calculate the amount invested in each of the four funds given the tot... |
evol_instruct_66k | 17,322 | Write a Python function to calculate the sum of numbers from 1 to a given number `n`. The function should handle both positive and negative integers, returning the sum of the absolute value of numbers from 1 to `abs(n)`. If `n` is zero, the function should return 0.
The code should start with:
```python
def sum_of_num... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_numbers(n: int) -> int:
"""
Calculate the sum of numbers from 1 to the absolute value of a given number n.
Args:
n (int): The number to calculate the sum up to.
Returns:
int: The sum of numbe... |
evol_instruct_66k | 17,331 | Write a Python function to sort the values of a dictionary by its keys in alphabetical order. The function should return a new dictionary with the keys sorted in alphabetical order. The original dictionary should remain unchanged.
The code should start with:
```python
from typing import Dict
def sort_dict_by_keys(dic... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def sort_dict_by_keys(dictionary: Dict[str, int]) -> Dict[str, int]:
"""
Sorts the values of a dictionary by its keys in alphabetical order.
Args:
dictionary (Dict[str, int]): The dictionary... |
evol_instruct_66k | 17,336 | Write a Python function to safely perform arithmetic operations on two integers, ensuring that no division by zero occurs. The function should return the result of the operations or a specific message if a division by zero is attempted. The operations to be performed are addition, subtraction, multiplication, and divis... | Here is the Python code to solve the given problem in the markdown block:
```python
def safe_arithmetic_operations(a: int, b: int) -> dict:
"""
Safely performs addition, subtraction, multiplication, and division on two integers.
If a division by zero is attempted, it returns a specific message indicating th... |
evol_instruct_66k | 17,337 | Write a Python function to calculate the square of a given number. The function should be able to handle both positive and negative integers, as well as zero. The code should start with:
```python
def squared(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def squared(num: int) -> int:
"""
Calculate the square of a given integer.
Args:
num (int): The integer to be squared.
Returns:
int: The square of the given integer.
"""
# Calculate the square... |
evol_instruct_66k | 17,340 | Write a Python function to merge consecutive duplicate elements in a given list into a single element. The function should iterate through the list and remove consecutive duplicates, keeping only one instance of each consecutive duplicate sequence. The code should start with:
```python
from typing import List
def merg... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_consecutive_duplicates(input_list: List[str]) -> List[str]:
"""
Merges consecutive duplicate elements in a given list into a single element.
Args:
input_list (List[str]): The list ... |
evol_instruct_66k | 17,341 | Write a Python function to transform a given list of integers into a dictionary where each key is an element from the list and the corresponding value is the square of that element. The function should handle lists with duplicate elements by ensuring that each element in the list appears only once as a key in the resul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def list_to_squared_dict(mylist: List[int]) -> Dict[int, int]:
"""
Transforms a list of integers into a dictionary where each key is an element from the list
and the corresponding value is the ... |
evol_instruct_66k | 17,342 | Write a Python function to find the third smallest number in a given list of integers without sorting the entire list. The function should have a time complexity no worse than O(n). The code should start with:
```python
from typing import List
def find_third_smallest(lst: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_third_smallest(lst: List[int]) -> int:
"""
Find the third smallest number in a given list of integers without sorting the entire list.
Args:
lst (List[int]): The list of integers fr... |
evol_instruct_66k | 17,359 | Write a Python function to count the occurrences of each alphabetic character in a given string and return the result as a dictionary. The function should be case-insensitive, meaning 'A' and 'a' should be considered the same character. The code should start with:
```python
from typing import Dict
def count_alphabetic... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_alphabetic_chars(input_string: str) -> Dict[str, int]:
"""
Counts the occurrences of each alphabetic character in the given string and returns the result as a dictionary.
Args:
inp... |
evol_instruct_66k | 17,360 | Write a Python function to remove uneven elements and non-integer elements from a nested mixed tuple. The function should recursively traverse the nested tuple and filter out any elements that are not integers or are uneven integers. The code should start with:
```python
from typing import Tuple
def remove_uneven_elem... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def remove_uneven_elements(nested_tuple: Tuple) -> Tuple:
"""
Recursively removes uneven elements and non-integer elements from a nested mixed tuple.
Args:
nested_tuple (Tuple): A nested tu... |
evol_instruct_66k | 17,368 | Write a Python function to determine if it is possible to complete all the courses given a certain number of courses and their prerequisites. Each course is labeled from `0` to `numCourses - 1`. The prerequisites are provided in an array where each element `prerequisites[i] = [ai, bi]` signifies that course `bi` must b... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def can_finish_courses(numCourses: int, prerequisites: List[List[int]]) -> bool:
"""
Determine if it is possible to complete all the courses given their prerequisites.
Args:
numCourses (int)... |
evol_instruct_66k | 17,369 | Write a Python function to combine two sequences of integers into a single list where elements from the first and second sequences alternate, and the resultant list is shuffled randomly. If the sequences are not of equal length, the extra elements from the longer sequence should be seamlessly incorporated into the fina... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
from itertools import zip_longest
def alternate_shuffle(seq1: List[int], seq2: List[int]) -> List[int]:
"""
Combines two sequences of integers into a single list where elements from the fir... |
evol_instruct_66k | 17,374 | Write a Python function to compute the union of two sets and return the resulting set. The function should handle sets of any size and ensure that the union operation is performed efficiently.
The code should start with:
```python
from typing import Set
def union_of_sets(set1: Set[int], set2: Set[int]) -> Set[int]:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set
def union_of_sets(set1: Set[int], set2: Set[int]) -> Set[int]:
"""
Computes the union of two sets and returns the resulting set.
Args:
set1 (Set[int]): The first set of integers.
set2... |
evol_instruct_66k | 17,376 | Write a Python function to reverse the digits of a given number without using any built-in reverse functions. The function should handle both positive and negative numbers. If the input number is negative, the function should return the reversed number as a negative. The code should start with:
```python
def reverse_di... | Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_digits(number: int) -> int:
"""
Reverses the digits of a given number without using any built-in reverse functions.
Args:
number (int): The number to be reversed.
Returns:
int: The number ... |
evol_instruct_66k | 17,377 | Write a Python function to convert a given matrix represented as a list of lists into a single list that maintains the order of elements as they appear in the matrix. The function should handle matrices of any size, including non-square matrices. The code should start with:
```python
from typing import List
def flatte... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def flatten_matrix(matrix: List[List[int]]) -> List[int]:
"""
Converts a given matrix represented as a list of lists into a single list that maintains the order of elements.
Args:
matrix (Li... |
evol_instruct_66k | 17,394 | Write a Python function to find and return the highest numerical value from a given list of numerical values. The function should handle lists of integers and floats. The code should start with:
```python
from typing import List, Union
def find_max_value(numbers: List[Union[int, float]]) -> Union[int, float]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_max_value(numbers: List[Union[int, float]]) -> Union[int, float]:
"""
Find and return the highest numerical value from a given list of numerical values.
Args:
numbers (List[U... |
evol_instruct_66k | 17,399 | Write a Python function to determine the maximum value between two given integers `x` and `y` using a more efficient algorithmic methodology. The function should return the larger of the two integers. The code should start with:
```python
def get_max_value(x: int, y: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def get_max_value(x: int, y: int) -> int:
"""
Returns the maximum value between two given integers.
Args:
x (int): The first integer to compare.
y (int): The second integer to compare.
Returns:
... |
evol_instruct_66k | 17,403 | Write a Python function to calculate the median salary of employees in an organization, grouped by department. The function should take a list of tuples as input, where each tuple contains an employee ID, department name, and salary. The function should return a dictionary where the keys are department names and the va... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def calculate_median_salaries(employees: List[Tuple[int, str, int]]) -> Dict[str, float]:
"""
Calculate the median salary of employees grouped by department.
Args:
employees (Li... |
evol_instruct_66k | 17,405 | Write a Python function to convert a given string from uppercase to lowercase. The function should handle any string input, including strings with mixed case characters. The code should start with:
```python
def convert_to_lowercase(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_lowercase(input_string: str) -> str:
"""
Converts a given string from uppercase to lowercase.
Args:
input_string (str): The string to be converted to lowercase.
Returns:
str: The lowercas... |
evol_instruct_66k | 17,406 | Write a Python function to find the second smallest element in a given array of integers. The function should handle arrays with duplicate elements and arrays with fewer than two elements by returning `None` in such cases. The code should start with:
```python
from typing import List, Optional
def find_second_smallest... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_second_smallest(array: List[int]) -> Optional[int]:
"""
Find the second smallest element in a given array of integers.
Args:
array (List[int]): The array of integers from ... |
evol_instruct_66k | 17,428 | Write a Python function to find the longest common subsequence (LCS) of two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) of two given strings.
Args:
str1 (str): The first string.
str2 (str): The secon... |
evol_instruct_66k | 17,436 | Write a Python function to create a 3D array of size 4x4x4 filled with random integers between -100 and 100, and then find the maximum value in the array along with its location (indices).
The code should start with:
```python
import numpy as np
def find_max_in_3d_array() -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def find_max_in_3d_array() -> tuple:
"""
Creates a 3D array of size 4x4x4 filled with random integers between -100 and 100,
and finds the maximum value in the array along with its location (indices).
... |
evol_instruct_66k | 17,477 | Write a Python function to perform a recursive binary search on a sorted list to find the index of a given value. If the value is not found, return -1. The function should start with:
```python
from typing import List
def binary_search(arr: List[int], value: int, low: int = 0, high: int = None) -> int:
```
| 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], value: int, low: int = 0, high: int = None) -> int:
"""
Perform a recursive binary search to find the index of a given value in a sorted list.
Args:
arr (Li... |
evol_instruct_66k | 17,480 | Write a Python function to calculate the sum of all numeric values within a multidimensional list. The function should handle nested lists and ignore any non-numeric values. The code should start with:
```python
from typing import List, Union
def sum_multidimensional_list(lst: List[Union[int, float, List]]) -> Union[i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def sum_multidimensional_list(lst: List[Union[int, float, List]]) -> Union[int, float]:
"""
Calculate the sum of all numeric values within a multidimensional list.
Args:
lst (List[Uni... |
evol_instruct_66k | 17,492 | Write a Python function to sort an array of floating point numbers from largest to smallest without using any in-built Python sorting functions. Additionally, implement error handling for non-float elements. The function should exclude non-float elements and print an error message for each such element.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_floats_descending(nums: List[float]) -> List[float]:
"""
Sorts an array of floating point numbers from largest to smallest without using any in-built Python sorting functions.
Non-float elem... |
evol_instruct_66k | 17,499 | Write a Python function to create a dictionary with three entries, where each entry consists of a key-value pair. The keys should be strings representing food items, and the values should be strings representing the category of the food item (e.g., 'fruit', 'vegetable', 'meat'). The function should return the construct... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_food_dictionary() -> dict:
"""
Creates a dictionary with three entries, where each entry consists of a key-value pair.
The keys are strings representing food items, and the values are strings representing the cate... |
evol_instruct_66k | 17,508 | Write a Python function that takes a list of values and returns a dictionary where the keys are the names of fundamental Python data types and the values are lists of values from the input list that belong to each corresponding data type. The function should handle the following data types: `int`, `float`, `str`, `list... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def categorize_data_types(values: List[Any]) -> Dict[str, List[Any]]:
"""
Categorizes a list of values by their Python data types.
Args:
values (List[Any]): A list of values to be... |
evol_instruct_66k | 17,555 | Write a Python function to calculate the maximum disparity between the smallest and largest integer in each sub-matrix of a given bi-dimensional matrix. The function should return a list of these disparities for each sub-matrix.
The code should start with:
```python
from typing import List
def find_disparities(matrix... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_disparities(matrix: List[List[int]]) -> List[int]:
"""
Calculate the maximum disparity between the smallest and largest integer in each sub-matrix of a given bi-dimensional matrix.
Args:
... |
evol_instruct_66k | 17,557 | Write a Python function to convert a given sentence into a grammatically correct headline-style string. The function should capitalize the first letter of each word, except for certain common articles, conjunctions, and prepositions that should remain in lowercase unless they are the first word of the headline. The fun... | Here is the Python code to solve the given problem in the markdown block:
```python
def headline_style_string(sentence: str) -> str:
"""
Converts a given sentence into a grammatically correct headline-style string.
Args:
sentence (str): The input sentence to be converted.
Returns:
str:... |
evol_instruct_66k | 17,571 | Write a Python function to create and return a dictionary that represents a person's professional and residential details. The dictionary should include the following fields:
1. **Work Sphere**: A string representing the person's profession.
2. **Length of Service (in Years)**: A string representing the duration of ser... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def create_professional_details(work_sphere: str, length_of_service: str, residential_surrounding: str = "Hub of the Universe - Boston") -> Dict[str, str]:
"""
Creates and returns a dictionary representi... |
evol_instruct_66k | 17,577 | Write a Python function to compute the square root of a given number without using any built-in square root functions, libraries, or calculator apps. The function should handle negative input values by raising an exception and should return the result with a precision of up to 8 decimal places. The input number will be... | Here is the Python code to solve the given problem in the markdown block:
```python
def compute_sqrt(n: float) -> float:
"""
Compute the square root of a given number without using any built-in square root functions.
Args:
n (float): The number for which to compute the square root. Must be in the r... |
evol_instruct_66k | 17,583 | Write a Python function to create a bi-dimensional array (2D list) composed purely of integer elements, having a specified number of horizontal data sets (rows) and vertical data sets (columns). The function should generate the array with sequential integers starting from 1. The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def create_bi_dim_array(rows: int, cols: int) -> List[List[int]]:
"""
Create a bi-dimensional array (2D list) composed purely of integer elements,
having a specified number of horizontal data sets (r... |
evol_instruct_66k | 17,607 | Write a Python function to reverse the order of elements in a given array without using any in-built or third-party library functions for reversing. The function should create a new array with the elements in reverse order and return it. The code should start with:
```python
from typing import List
def reverse_array(i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_array(input_array: List[int]) -> List[int]:
"""
Reverses the order of elements in a given array without using any in-built or third-party library functions for reversing.
Args:
i... |
evol_instruct_66k | 17,612 | Write a Python function to sort a given list of integers in ascending order using the merge sort algorithm. The function should be efficient and handle edge cases such as an empty list or a list with a single element. The code should start with:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers in ascending order using the merge sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Re... |
evol_instruct_66k | 17,613 | Write a Python function to generate the Fibonacci sequence up to the nth number and calculate the greatest common divisor (GCD) for every pair of adjacent Fibonacci numbers. The function should ensure that the runtime complexity does not exceed O(n * log n).
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 gcd(a: int, b: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
Args:
a (int): The first number.
b (int): The second num... |
evol_instruct_66k | 17,620 | Write a Python function to arrange the elements of a given list in descending order. The function should take a list of integers as input and return a new list with the elements sorted in descending order. The original list should not be modified.
The code should start with:
```python
from typing import List
def sort... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_descending(elements: List[int]) -> List[int]:
"""
Sorts the elements of a given list in descending order.
Args:
elements (List[int]): The list of integers to be sorted.
Returns... |
evol_instruct_66k | 17,635 | Write a Python function to find the largest element in a given list of integers and return both the largest element and its index. The function should also print the intermediate steps of the comparison process, showing whether each element is greater than the current largest element.
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, Tuple
def find_largest_element(nums: List[int]) -> Tuple[int, int]:
"""
Finds the largest element in a list of integers and returns both the element and its index.
Also prints the intermediate steps... |
evol_instruct_66k | 17,636 | Write a Python function to remove all occurrences of a specified entity from a given list of data. The function should return a new list that excludes the specified entity. The code should start with:
```python
from typing import List
def remove_entity(data: List[int], entity: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def remove_entity(data: List[int], entity: int) -> List[int]:
"""
Removes all occurrences of a specified entity from a given list of data.
Args:
data (List[int]): The list of integers from... |
evol_instruct_66k | 17,653 | Write a Python function to find the shortest sentence from a given list of sentences. The function should return the shortest sentence as a string. If there are multiple sentences with the same minimum length, the function should return the first one encountered.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_shortest_sentence(sentences: List[str]) -> str:
"""
Finds the shortest sentence from a given list of sentences.
Args:
sentences (List[str]): A list of sentences from which to find t... |
evol_instruct_66k | 17,661 | Write a Python function to merge two dictionaries with alphabetical keys and numerical values into a single dictionary. If there are overlapping keys, the value from the second dictionary should overwrite the value from the first dictionary. The function should be efficient and handle any size of input dictionaries.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def merge_dictionaries(dictA: Dict[str, int], dictB: Dict[str, int]) -> Dict[str, int]:
"""
Merge two dictionaries with alphabetical keys and numerical values into a single dictionary.
If there are o... |
evol_instruct_66k | 17,679 | Write a Python function to generate and store combinations of numbers from two nested loops. The outer loop should iterate over the numbers 1 to 10, and the inner loop should iterate over the numbers from the current number of the outer loop to 10. Each combination should be stored in a dictionary with the key being a ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def generate_combinations() -> Dict[str, bool]:
"""
Generate and store combinations of numbers from two nested loops.
Returns:
Dict[str, bool]: A dictionary containing all the gene... |
evol_instruct_66k | 17,690 | Write a Python function to calculate the Hamming distance between two binary sequences. The Hamming distance is defined as the number of positions at which the corresponding bits are different. The function should take two binary sequences as input and return the Hamming distance as an integer.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
def hamming_distance(bin_seq1: str, bin_seq2: str) -> int:
"""
Calculate the Hamming distance between two binary sequences.
The Hamming distance is the number of positions at which the corresponding bits are different.
... |
evol_instruct_66k | 17,696 | Write a Python function to merge two pre-sorted lists into a single sorted list. The function should ensure that the merged list remains sorted. The code should start with:
```python
from typing import List
def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
```
| 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 lists into a single sorted list.
Args:
arr1 (List[int]): The first pre-sorted list.
... |
evol_instruct_66k | 17,701 | Write a Python function to determine if a specified integer exists within a multi-dimensional numerical array (nested up to 3 levels deep). If the integer is found, return the path to the integer as a list of indices. If the integer is not found, return `None`.
The code should start with:
```python
from typing import ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union, Optional
def find_path_to_element(arr: List[Union[int, List[Union[int, List[int]]]]], x: int) -> Optional[List[int]]:
"""
Find the path to a specified integer in a multi-dimensional array (nested... |
evol_instruct_66k | 17,702 | Write a Python function to compute and return the squares of each element in a given list. The function should use a single `while` loop to traverse the list and compute the squares. The result should be returned as a new list containing the squares of the original list's elements.
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
def compute_squares(numbers: List[int]) -> List[int]:
"""
Compute the squares of each element in the given list and return a new list containing these squares.
Args:
numbers (List[int]): The... |
evol_instruct_66k | 17,709 | Write a Python function to calculate the arithmetic mean of all even numbers in a given list. The function should exclude all odd numbers from the calculation. The code should start with:
```python
from typing import List
def arithmetic_mean_of_evens(numbers: List[int]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def arithmetic_mean_of_evens(numbers: List[int]) -> float:
"""
Calculate the arithmetic mean of all even numbers in the given list.
Args:
numbers (List[int]): The list of integers from which... |
evol_instruct_66k | 17,715 | Write a Python function to construct a SQL query that selects the names, age, and department of all employees who have a salary greater than 45000 and have not received a salary increment in the last two years. The database contains over 500,000 records with the following columns: `id`, `name`, `age`, `department`, `sa... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime, timedelta
def construct_sql_query() -> str:
"""
Constructs a SQL query to select the names, age, and department of all employees
who have a salary greater than 45000 and have not received a sa... |
evol_instruct_66k | 17,716 | Write a Python function to generate a SQL query for an API endpoint that extracts data from a relational database table and optionally manipulates the data by applying a condition, performing a join operation with another table, or sorting the data. The function should be flexible enough to handle different combination... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_sql_query(table: str, secondary_table: str = None, condition: str = None, sorting: str = None) -> str:
"""
Generates a SQL query for an API endpoint to extract and manipulate data from a relational database table.
... |
evol_instruct_66k | 17,720 | Write a Python function to determine if a given integer `n` can be rearranged to form a power of 2. The rearrangement must ensure that the leading digit is not zero. The function should return `true` if such a rearrangement is possible, and `false` otherwise.
The code should start with:
```python
def can_reorder_to_po... | Here is the Python code to solve the given problem in the markdown block:
```python
def can_reorder_to_power_of_2(n: int) -> bool:
"""
Determines if the digits of the given integer `n` can be rearranged to form a power of 2.
Args:
n (int): The integer to check for reordering to a power of 2.
R... |
evol_instruct_66k | 17,721 | 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 | 17,726 | Write a Python function to reverse the digits of a given integer. The function should handle both positive and negative integers. If the input number is negative, the function should return the reversed number with a negative sign. The code should start with:
```python
def reverse_integer(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_integer(n: int) -> int:
"""
Reverses the digits of a given integer. If the input number is negative, the reversed number will also be negative.
Args:
n (int): The integer to be reversed.
Returns:
... |
evol_instruct_66k | 17,730 | Write a Python function to perform basic arithmetic operations on two integers and return the results as a dictionary. The operations to be performed are addition, subtraction, multiplication, division, and modulus. The function should handle the case where the second integer is zero for division and modulus operations... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
def arithmetic_operations(num1: int, num2: int) -> Dict[str, Union[int, float, None]]:
"""
Perform basic arithmetic operations on two integers and return the results as a dictionary.
Args:
... |
evol_instruct_66k | 17,738 | Write a Python function to locate the positions of every instance of a specific integer within a given array. The function should return a list of indices where the specified integer appears in the array.
The code should start with:
```python
from typing import List
def find_positions(array: List[int], integer: int) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_positions(array: List[int], integer: int) -> List[int]:
"""
Locate the positions of every instance of a specific integer within a given array.
Args:
array (List[int]): The array in ... |
evol_instruct_66k | 17,743 | Write a Python function to generate the first `n` Fibonacci numbers. The function should return a list of the first `n` Fibonacci numbers. If `n` is less than or equal to 0, the function should return an empty list.
The code should start with:
```python
from typing import List
def generate_fibonacci(n: int) -> List[i... | 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 | 17,748 | Write a Python function to generate an 'n x n' identity matrix and convert it to a sparse matrix representation. The identity matrix should have 1s on the diagonal and 0s elsewhere. The sparse matrix representation should be a list of tuples, where each tuple contains the row index, column index, and the value of the n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def generate_identity_matrix(n: int) -> List[List[int]]:
"""
Generate an 'n x n' identity matrix.
Args:
n (int): The size of the identity matrix.
Returns:
List[List[int]]... |
evol_instruct_66k | 17,780 | Write a Python function to calculate the mean of a given dataset and return it as a float rounded to two decimal places. The dataset is a list of floating-point numbers. The function should handle datasets of any size, not just limited to 10 elements.
The code should start with:
```python
from typing import List
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_mean(data_set: List[float]) -> float:
"""
Calculate the mean of a given dataset and return it as a float rounded to two decimal places.
Args:
data_set (List[float]): The datase... |
evol_instruct_66k | 17,789 | Write a Python function to identify and return a list of integers that appear more than once in a given list of integers. The function should efficiently handle the input list and return the duplicates in any order.
The code should start with:
```python
from typing import List
def find_duplicates(data: List[int]) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import defaultdict
def find_duplicates(data: List[int]) -> List[int]:
"""
Identify and return a list of integers that appear more than once in the given list.
Args:
data (Li... |
evol_instruct_66k | 17,790 | Write a Python function to get the current time and date in the specified time zone and format it as `YYYY/MM/DD hh:mm:ss`. The function should accept a time zone string as input and return the formatted date and time string.
The code should start with:
```python
from datetime import datetime
import pytz
def get_curr... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
import pytz
def get_current_datetime_in_timezone(timezone: str) -> str:
"""
Get the current date and time in the specified time zone and format it as YYYY/MM/DD hh:mm:ss.
Args:
timezon... |
evol_instruct_66k | 17,796 | Write a Python function to print the elements of a 2D array. The function should take the 2D array, the number of rows, and the number of columns as arguments. Ensure that the function handles the bounds correctly and prints each element in the correct order.
The code should start with:
```python
from typing import Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_2d_array(arr: List[List[int]], m: int, n: int) -> None:
"""
Prints the elements of a 2D array.
Args:
arr (List[List[int]]): The 2D array to be printed.
m (int): The number ... |
evol_instruct_66k | 17,798 | Write a Python function to retrieve the first occurrence of a specified element from a tuple that may contain duplicate elements. The function should return the index of the first occurrence of the specified element. If the element is not found, the function should return -1.
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 Tuple, Any
def find_first_occurrence(elements: Tuple[Any, ...], target: Any) -> int:
"""
Find the index of the first occurrence of a specified element in a tuple.
Args:
elements (Tuple[Any, ...])... |
evol_instruct_66k | 17,819 | Write a Python function to calculate the aggregate of two distinct integers `x` and `y`. The function should handle any integer values for `x` and `y` and return their sum. The code should start with:
```python
def aggregate_two_integers(x: int, y: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def aggregate_two_integers(x: int, y: int) -> int:
"""
Calculate the sum of two distinct integers x and y.
Args:
x (int): The first integer.
y (int): The second integer.
Returns:
int: The sum of... |
evol_instruct_66k | 17,831 | Write a Python function to split a given string into words while maintaining punctuation within words (e.g., "I'm", "don't") as single entities and treating multiple continuous white spaces as a single separator. The function should return a list of words.
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
import re
def split_text(text: str) -> List[str]:
"""
Splits a given string into words while maintaining punctuation within words
(e.g., "I'm", "don't") as single entities and treating multiple conti... |
evol_instruct_66k | 17,847 | Write a Python function to calculate the sum of the squares of all even integers in a given list. The function should only consider even integers and ignore any other types of elements in the list.
The code should start with:
```python
from typing import List
def sum_of_even_squares(lst: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_even_squares(lst: List[int]) -> int:
"""
Calculate the sum of the squares of all even integers in the given list.
Args:
lst (List[int]): The list of integers from which to calcula... |
evol_instruct_66k | 17,850 | Write a Python function to perform a loop that iterates exactly 10 times, printing the current iteration number each time. The function should start with:
```python
def print_iterations(n: int) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def print_iterations(n: int) -> None:
"""
Prints the iteration number for each of the first n iterations.
Args:
n (int): The number of iterations to perform.
Returns:
None: This function does not retu... |
evol_instruct_66k | 17,873 | Write a Python function to shuffle a given list in place. The function should modify the original list and return it. The shuffling should be done using the Fisher-Yates algorithm, which ensures a uniform random permutation of the list.
The code should start with:
```python
from typing import List
def shuffle_list(ls... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def shuffle_list(lst: List[int]) -> List[int]:
"""
Shuffles the given list in place using the Fisher-Yates algorithm.
Args:
lst (List[int]): The list to be shuffled.
Retur... |
evol_instruct_66k | 17,876 | Write a Python function to find the maximum number in a given list of integers. The function should return the largest integer in the list. The code should start with:
```python
from typing import List
def find_max_number(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_max_number(numbers: List[int]) -> int:
"""
Find the maximum number in a given list of integers.
Args:
numbers (List[int]): A list of integers from which to find the maximum number.
... |
evol_instruct_66k | 17,883 | Write a Python function to swap the values of two arrays of equal length without using any additional data structures. The function should handle arrays of any length, including arrays of length one. The code should start with:
```python
from typing import List
def swap_arrays(array1: List[int], array2: List[int]) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def swap_arrays(array1: List[int], array2: List[int]) -> (List[int], List[int]):
"""
Swaps the values of two arrays of equal length without using any additional data structures.
Args:
array1... |
evol_instruct_66k | 17,888 | Write a Python function to compute the Least Common Multiple (LCM) of three distinct positive integers. The function should use the Euclidean algorithm to compute the Greatest Common Divisor (GCD) as an intermediate step. The code should start with:
```python
def lcm_of_three(a: int, b: int, c: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def gcd(a: int, b: int) -> int:
"""
Compute the greatest common divisor of a and b using the Euclidean algorithm.
Args:
a (int): The first positive integer.
b (int): The second positive integer.
Returns... |
evol_instruct_66k | 17,893 | Write a Python function to convert a binary input (string) to its hexadecimal representation (string). The function should handle binary strings of any length and return the hexadecimal representation in uppercase letters. The code should start with:
```python
def binary_to_hex(b: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_hex(b: str) -> str:
"""
Convert a binary input (string) to its hexadecimal representation (string).
Args:
b (str): The binary string to be converted.
Returns:
str: The hexadecimal represen... |
evol_instruct_66k | 17,910 | Write a Python function to find the three largest and three smallest elements in a given array without sorting or altering the original array. The function should return two lists: one containing the three largest elements and the other containing the three smallest elements. 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 find_three_largest_and_smallest(array: List[int]) -> Tuple[List[int], List[int]]:
"""
Finds the three largest and three smallest elements in the given array without sorting or altering the ori... |
evol_instruct_66k | 17,918 | Write a Python function to swap the first and last elements of a given list while maintaining the order of the remaining elements. If the list has fewer than two elements, it should return the list unchanged. The function should be named `swap_first_and_last` and 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 swap_first_and_last(my_list: List) -> List:
"""
Swaps the first and last elements of the given list while maintaining the order of the remaining elements.
Args:
my_list (List): The list ... |
evol_instruct_66k | 17,934 | Write a Python function to construct a tuple containing multiple elements, where each element is a string. The function should accept a list of strings as input and return a tuple containing these strings. The function should also ensure that the input list contains only strings and handle cases where the input list is... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def construct_string_tuple(strings: List[str]) -> Tuple[str, ...]:
"""
Constructs a tuple containing multiple elements, where each element is a string.
Args:
strings (List[str]): A li... |
evol_instruct_66k | 17,938 | Write a Python function to print the squares of numbers in a given range, incrementing by a specified step. The function should take three parameters: the starting number, the ending number (exclusive), and the step size. The function should print the square of each number in the range, starting from the starting numbe... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_squares_in_range(start: int, end: int, step: int) -> None:
"""
Prints the squares of numbers in a given range, incrementing by a specified step.
Args:
start (int): The starting number of the range.
... |
evol_instruct_66k | 17,970 | Write a Python function to compute the factorial of a given non-negative integer using a for-loop. The function should handle the case where the input number is 0 by returning 1, as the factorial of 0 is defined to be 1. The function should also handle larger numbers efficiently.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def compute_factorial(n: int) -> int:
"""
Compute the factorial of a given non-negative integer using a for-loop.
Args:
n (int): The non-negative integer for which to compute the factorial.
Returns:
int... |
evol_instruct_66k | 17,992 | Write a Python function to find the indices of all occurrences of a given item in an array without using built-in methods. The function should iterate through the array and collect the indices where the item is found. The code should start with:
```python
from typing import List
def find_indices_of_item(arr: List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_indices_of_item(arr: List[int], item: int) -> List[int]:
"""
Find the indices of all occurrences of a given item in an array.
Args:
arr (List[int]): The array in which to search for... |
evol_instruct_66k | 18,009 | 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 | 18,010 | Write a Python function to quantify the frequency of lists present within a given list. The function should yield a dictionary where each list is transformed into a tuple, and the corresponding value of the tuple signifies the count of its appearances. The function should also be capable of managing nested lists by fla... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, List, Dict, Tuple
from collections import defaultdict
def flatten(lst: List[Any]) -> List[Any]:
"""
Recursively flattens a nested list.
Args:
lst (List[Any]): The list to be flattened.
... |
evol_instruct_66k | 18,012 | Write a Python function to merge two dictionaries by summing the values of corresponding keys. If a key exists in only one dictionary, it should be included in the result with its value unchanged. The function should handle dictionaries with integer values.
The code should start with:
```python
from typing import Dict... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def merge_dicts_sum_values(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]:
"""
Merges two dictionaries by summing the values of corresponding keys.
Args:
dict1 (Dict[str, in... |
evol_instruct_66k | 18,018 | Write a Python function to calculate the number of ways to climb a staircase with `n` steps, where a person can take either 1 or 2 steps at a time. The function should use dynamic programming to efficiently compute the result.
The code should start with:
```python
def climb_stairs(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def climb_stairs(n: int) -> int:
"""
Calculate the number of ways to climb a staircase with n steps, where a person can take either 1 or 2 steps at a time.
Args:
n (int): The number of steps in the staircase.
R... |
evol_instruct_66k | 18,022 | Write a Python function to remove all punctuation marks from a given ASCII string. The function should return the cleaned string without any punctuation. The code should start with:
```python
from typing import List
def remove_punctuation(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def remove_punctuation(sentence: str) -> str:
"""
Removes all punctuation marks from the given ASCII string.
Args:
sentence (str): The input string from which punctuation marks... |
evol_instruct_66k | 18,025 | Write a Python function to determine the event that was triggered the most times from a given state dictionary. The state dictionary tracks the number of times each of the events "onMouseLeave", "onClick", and "onMouseEnter" has been triggered. The function should return a list containing the name of the event that was... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple
def most_triggered_event(state: Dict[str, int]) -> List[str]:
"""
Determine the event that was triggered the most times from a given state dictionary.
Args:
state (Dict[str, int... |
evol_instruct_66k | 18,030 | Write a Python function to report contiguous dates and associated data for a given dataset. The dataset is a list of tuples, where each tuple contains a date (in string format 'YYYY-MM-DD'), a user ID, and an activity type. The function should group contiguous dates by user and activity, and return a list of tuples, wh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from datetime import datetime
def report_contiguous_dates(data: List[Tuple[str, int, str]]) -> List[Tuple[str, str, int, str]]:
"""
Report contiguous dates and associated data for a given dataset.... |
evol_instruct_66k | 18,038 | Write a Python function to perform a series of string manipulations on a given input string. The function should:
1. Remove leading and trailing whitespace.
2. Convert the string to lowercase.
3. Replace all occurrences of the word "World" with "Python".
4. Split the string into a list of words.
5. Join the list of wor... | Here is the Python code to solve the given problem in the markdown block:
```python
def manipulate_string(input_str: str) -> str:
"""
Perform a series of string manipulations on the given input string.
Args:
input_str (str): The input string to be manipulated.
Returns:
str: The final m... |
evol_instruct_66k | 18,041 | Write a Python function named `lowest_common_multiple` that calculates the smallest common multiple (LCM) of two integer arguments, `x` and `y`. The function must ensure that both `x` and `y` are positive integers within the range of 1 to 1000. If either `x` or `y` is outside this range, the function should raise a `Va... | Here is the Python code to solve the given problem in the markdown block:
```python
def lowest_common_multiple(x: int, y: int) -> int:
"""
Calculate the smallest common multiple (LCM) of two integers x and y.
Args:
x (int): The first integer, must be within the range [1, 1000].
y (int): The... |
evol_instruct_66k | 18,062 | Write a Python function to generate a palindrome sequence from a given queue of strings. The function should append the elements of the queue in reverse order to the original queue to form a palindrome sequence. If the original queue is already a palindrome, it should return the original queue unchanged.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_palindrome_sequence(queue: List[str]) -> List[str]:
"""
Generates a palindrome sequence from a given queue of strings.
Args:
queue (List[str]): The input queue of strings.
... |
evol_instruct_66k | 18,078 | Write a Python function to analyze a given string and determine if it ends with the substring "py". Additionally, the function should count the number of occurrences of "py" in the string and provide the positions of each occurrence. The function should return a dictionary with the following keys: `"ends_with_py"` (a b... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import Dict, List, Tuple
def scrutinise_string(s: str) -> Dict[str, object]:
"""
Analyzes the given string to determine if it ends with the substring "py",
counts the number of occurrences of "py", and... |
evol_instruct_66k | 18,080 | Write a Python function to determine the top three most frequently occurring words in a given text, ignoring case sensitivity and punctuation. The function should also handle special cases such as empty or null text.
The code should start with:
```python
from typing import List, Optional
def top_three_frequent_words(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
import re
import collections
def top_three_frequent_words(text: Optional[str]) -> List[str]:
"""
Determine the top three most frequently occurring words in the given text, ignoring case sensiti... |
evol_instruct_66k | 18,116 | Write a Python function to calculate the cumulative sum of every individual element within a provided list. The cumulative sum for a list `[a, b, c, ...]` is defined as `[a, a+b, a+b+c, ...]`. The function should be efficient and handle lists of various lengths, including empty lists.
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
def cumulative_sum(lst: List[int]) -> List[int]:
"""
Calculate the cumulative sum of every individual element within a provided list.
Args:
lst (List[int]): The list of integers for which to... |
evol_instruct_66k | 18,125 | Write a Python function to calculate the sum of the first `N-1` elements from a given list of integers. The function should handle cases where `N` is less than or equal to 1, returning 0 in such cases. The code should start with:
```python
from typing import List
def sum_first_n_minus_one(X: List[int], N: int) -> int:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_first_n_minus_one(X: List[int], N: int) -> int:
"""
Calculate the sum of the first N-1 elements from the given list.
Args:
X (List[int]): The list of integers from which to calculate... |
evol_instruct_66k | 18,128 | Write a Python function to efficiently manage a library of musical compositions. The function should allow sorting the compositions by the year of composition, searching for a specific composer or composition title, and handle possible exceptions through error logging. The function should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def manage_music_library(compositions: List[Dict[str, Union[str, int]]], operation: str, query: Union[str, int] = None) -> Union[List[Dict[str, Union[str, int]]], str]:
"""
Manages a library... |
evol_instruct_66k | 18,150 | Write a Python function to create a dictionary where the keys are the strings from a given list and the values are the lengths of those strings. The function should handle an empty list gracefully and ensure that the dictionary is correctly populated with the string lengths.
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, Dict
def string_lengths_to_dict(arr: List[str]) -> Dict[str, int]:
"""
Creates a dictionary where the keys are the strings from the input list and the values are the lengths of those strings.
Args:... |
evol_instruct_66k | 18,175 | Write a Python function to calculate the maximum number of distinct values that can be inserted into a binary search tree (BST) containing a given number of nodes, ensuring that the tree remains balanced after each insertion. The function should take the number of nodes as input and return the maximum number of distinc... | Here is the Python code to solve the given problem in the markdown block:
```python
def max_distinct_values_in_balanced_bst(num_nodes: int) -> int:
"""
Calculate the maximum number of distinct values that can be inserted into a balanced binary search tree
containing a given number of nodes.
Args:
... |
evol_instruct_66k | 18,192 | Write a Python function to remove keys from a dictionary where the values are considered "empty". An empty value is defined as `None`, `False`, `0`, or an empty string `''`. The function should return a new dictionary with the empty values removed.
The code should start with:
```python
from typing import Dict, Any
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def remove_empty_values(my_dict: Dict[Any, Any]) -> Dict[Any, Any]:
"""
Removes keys from the dictionary where the values are considered "empty".
Args:
my_dict (Dict[Any, Any]): The inp... |
evol_instruct_66k | 18,206 | Write a Python function to count the number of vowels in a given string, considering both uppercase and lowercase vowels. The function should be case-insensitive and should return the total count of vowels in the string.
The code should start with:
```python
def count_vowels(text: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels(text: str) -> int:
"""
Count the number of vowels in a given string.
Args:
text (str): The input string in which to count the vowels.
Returns:
int: The total number of vowels in the inp... |
evol_instruct_66k | 18,212 | Write a Python function to create a dictionary representing an entity with three distinct attributes: 'name', 'age', and 'employment_designation'. The function should take three parameters corresponding to these attributes and return the constructed dictionary.
The code should start with:
```python
from typing import ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def create_entity(name: str, age: int, employment_designation: str) -> Dict[str, object]:
"""
Creates a dictionary representing an entity with three attributes: 'name', 'age', and 'employment_designation... |
evol_instruct_66k | 18,216 | Write a Python function to reverse a given string while maintaining the same characters. The function should handle strings of varying lengths, including empty strings. The code should start with:
```python
def reverse_string(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(text: str) -> str:
"""
Reverses the given string while maintaining the same characters.
Args:
text (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# U... |
evol_instruct_66k | 18,217 | Write a Python function to determine if every alphabetical character in a given text sequence is unique. The function should be case-insensitive and should ignore non-alphabetical characters and spaces. The code should start with:
```python
def has_unique_chars(text_sequence: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def has_unique_chars(text_sequence: str) -> bool:
"""
Determines if every alphabetical character in the given text sequence is unique.
The function is case-insensitive and ignores non-alphabetical characters and spaces.
... |
evol_instruct_66k | 18,227 | Write a Python function to transform a multi-dimensional array into a string of comma-separated values. The array is irregular, meaning some elements could be arrays themselves. Ensure that no square brackets are present in the final string. Nested arrays should be flattened before being transformed.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def flatten(input_list: List[Any]) -> List[Any]:
"""
Recursively flattens a multi-dimensional list into a single-dimensional list.
Args:
input_list (List[Any]): The multi-dimensional li... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.