source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
code_exercise_27k
1,646
Write a Python function named `calculate_area_of_rectangle` that takes two float numbers as input: `length` and `width`. The function should calculate and return the area of a rectangle using the formula: `area = length * width`. The function should also handle cases where the input values are zero or negative by retur...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_area_of_rectangle(length: float, width: float) -> float: """ Calculate the area of a rectangle given its length and width. This function takes two float numbers as input: length and width. It calculates and re...
code_exercise_27k
1,648
Write a Python function named `calculate_area_of_square` that takes a float number as input: `side`. The function should calculate and return the area of a square using the formula: `area = side^2`. The function should also handle cases where the input is zero or negative by returning `None`. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_area_of_square(side: float) -> float: """ Calculate the area of a square given the length of one of its sides. Args: side (float): The length of a side of the square. Returns: float: The a...
code_exercise_27k
1,649
Write a Python function named `calculate_area_of_square` that takes a float number as input: `side`. The function should calculate and return the area of a square using the formula: `area = side * side`. The code should start with: ```python def calculate_area_of_square(side: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_area_of_square(side: float) -> float: """ Calculate the area of a square given the length of one of its sides. Args: side (float): The length of a side of the square. Returns: float: The a...
code_exercise_27k
1,650
Write a Python function named `calculate_volume_of_cube` that takes a float number as input: `side`. The function should calculate and return the volume of a cube using the formula: `volume = side^3`. The code should start with: ```python def calculate_volume_of_cube(side: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_volume_of_cube(side: float) -> float: """ Calculate the volume of a cube given the length of one of its sides. Args: side (float): The length of a side of the cube. Returns: float: The vol...
code_exercise_27k
1,654
Write a Python function to add two complex numbers and return their sum. The function should handle complex numbers in the form of `a + bj`, where `a` and `b` are real numbers and `j` is the imaginary unit. The function should be named `add_complex` and should accept two complex numbers as input parameters. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python def add_complex(num1: complex, num2: complex) -> complex: """ Adds two complex numbers and returns their sum. Args: num1 (complex): The first complex number. num2 (complex): The second complex number. R...
code_exercise_27k
1,655
Write a Python function to subtract two complex numbers and return their difference. The function should handle complex numbers in the form of `a + bj`, where `a` and `b` are real numbers and `j` is the imaginary unit. The code should start with: ```python def subtract_complex(num1: complex, num2: complex) -> complex: ...
Here is the Python code to solve the given problem in the markdown block: ```python def subtract_complex(num1: complex, num2: complex) -> complex: """ Subtracts two complex numbers and returns their difference. Args: num1 (complex): The first complex number. num2 (complex): The second compl...
code_exercise_27k
1,658
Write a Python function to find the conjugate of a given complex number. The function should take a complex number as input and return its conjugate. The conjugate of a complex number \( a + bi \) is \( a - bi \), where \( a \) and \( b \) are real numbers and \( i \) is the imaginary unit. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python def conjugate_complex(num: complex) -> complex: """ Returns the conjugate of a given complex number. Args: num (complex): The complex number for which to find the conjugate. Returns: complex: The conjug...
code_exercise_27k
1,659
Write a Python function named `absolute_complex` that takes a complex number as input and returns its absolute value. The function should handle complex numbers in the form of `a + bj`, where `a` and `b` are real numbers and `j` is the imaginary unit. The absolute value of a complex number `a + bj` is defined as the sq...
Here is the Python code to solve the given problem in the markdown block: ```python def absolute_complex(num: complex) -> float: """ Calculate the absolute value of a given complex number. Args: num (complex): The complex number for which to calculate the absolute value. Returns: float...
code_exercise_27k
1,660
Write a Python function named `imaginary_part` that takes a complex number as input and returns its imaginary part. The function should be able to handle complex numbers in the form of `a + bj`, where `a` and `b` are real numbers and `j` is the imaginary unit. The code should start with: ```python def imaginary_part(nu...
Here is the Python code to solve the given problem in the markdown block: ```python def imaginary_part(num: complex) -> float: """ Returns the imaginary part of a given complex number. Args: num (complex): The complex number from which to extract the imaginary part. Returns: float: The...
code_exercise_27k
1,663
Write a Python function to calculate the magnitude of a complex number. The function should take a complex number as input and return its magnitude as a float. The code should start with: ```python import cmath def magnitude_complex(num: complex) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python import cmath def magnitude_complex(num: complex) -> float: """ Calculate the magnitude of a given complex number. Args: num (complex): The complex number for which to calculate the magnitude. Returns: ...
code_exercise_27k
1,664
Write a Python function named `angle_complex` that takes a complex number as input and returns its angle in radians. The function should use the `cmath` module to compute the angle. The code should start with: ```python import cmath def angle_complex(num: complex) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python import cmath def angle_complex(num: complex) -> float: """ Computes the angle (in radians) of a given complex number. Args: num (complex): The complex number for which to compute the angle. Returns: fl...
code_exercise_27k
1,667
Write a Python function named `log_complex` that takes a complex number as input and returns its natural logarithm. The function should handle complex numbers and return the result as a complex number. The code should start with: ```python import cmath def log_complex(num: complex) -> complex: ```
Here is the Python code to solve the given problem in the markdown block: ```python import cmath def log_complex(num: complex) -> complex: """ Calculate the natural logarithm of a complex number. Args: num (complex): The complex number for which to calculate the natural logarithm. Returns: ...
code_exercise_27k
1,674
Write a Python function named `floor_complex` that takes a complex number as input and returns a complex number with the real and imaginary parts rounded down to the nearest integer. The function should handle both positive and negative parts of the complex number. The code should start with: ```python import math def...
Here is the Python code to solve the given problem in the markdown block: ```python import math def floor_complex(num: complex) -> complex: """ Rounds down the real and imaginary parts of a complex number to the nearest integer. Args: num (complex): The complex number to be processed. Returns...
code_exercise_27k
1,675
Write a Python function named `ceil_complex` that takes a complex number as input and returns a complex number with the real and imaginary parts rounded up to the nearest integer. The function should handle both positive and negative parts of the complex number. The code should start with: ```python import math def ce...
Here is the Python code to solve the given problem in the markdown block: ```python import math def ceil_complex(num: complex) -> complex: """ Rounds up the real and imaginary parts of a complex number to the nearest integer. Args: num (complex): The complex number to be processed. Returns: ...
code_exercise_27k
1,676
Write a Python function named `round_complex` that takes a complex number as input and returns a complex number with the real and imaginary parts rounded to the nearest integer. The function should handle both positive and negative real and imaginary parts. The code should start with: ```python def round_complex(num: c...
Here is the Python code to solve the given problem in the markdown block: ```python def round_complex(num: complex) -> complex: """ Rounds the real and imaginary parts of a complex number to the nearest integer. Args: num (complex): The complex number to be rounded. Returns: complex: A...
code_exercise_27k
1,677
Write a Python function to determine if a given complex number is purely real. The function should return `True` if the imaginary part of the complex number is zero, and `False` otherwise. The function should be named `is_real` and should accept a single parameter, which is a complex number. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python def is_real(num: complex) -> bool: """ Determines if a given complex number is purely real. Args: num (complex): The complex number to be checked. Returns: bool: True if the complex number is purely rea...
code_exercise_27k
1,678
Write a Python function to determine if a given complex number is purely imaginary, meaning it has no real part (i.e., the real part is 0). The function should return `True` if the complex number is purely imaginary and `False` otherwise. The code should start with: ```python def is_purely_imaginary(num: complex) -> bo...
Here is the Python code to solve the given problem in the markdown block: ```python def is_purely_imaginary(num: complex) -> bool: """ Determines if a given complex number is purely imaginary. A complex number is considered purely imaginary if its real part is 0. Args: num (complex): The compl...
code_exercise_27k
1,679
Write a Python function named `complex_to_string` that takes a complex number as input and returns a string representation of the complex number in the form "a + bi", where "a" is the real part and "b" is the imaginary part. The function should handle both positive and negative imaginary parts correctly, ensuring that ...
Here is the Python code to solve the given problem in the markdown block: ```python def complex_to_string(num: complex) -> str: """ Converts a complex number to its string representation in the form "a + bi". Args: num (complex): The complex number to be converted. Returns: str: The st...
code_exercise_27k
1,720
Write a Python function named `subtract_numbers` that takes two parameters, `num1` and `num2`, and returns the difference between the two numbers. The function should handle both integer and floating-point numbers. The code should start with: ```python def subtract_numbers(num1: int | float, num2: int | float) -> int |...
Here is the Python code to solve the given problem in the markdown block: ```python def subtract_numbers(num1: int | float, num2: int | float) -> int | float: """ This function takes two numbers as input and returns their difference. Parameters: num1 (int or float): The first number. num2 (int or f...
code_exercise_27k
1,722
Write a Python function named `absolute_value` that takes a parameter `num` and returns the absolute value of the number. The function should handle both integer and floating-point numbers. The code should start with: ```python def absolute_value(num: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def absolute_value(num: float) -> float: """ Returns the absolute value of the given number. Args: num (float): The number whose absolute value is to be determined. Returns: float: The absolute value of...
code_exercise_27k
1,723
Write a Python function named `is_positive` that takes a parameter `num` and returns `True` if the number is positive (greater than 0), and `False` otherwise. The function should handle both integers and floating-point numbers. The code should start with: ```python def is_positive(num: int | float) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_positive(num: int | float) -> bool: """ Determines if the given number is positive. This function takes a number as input and returns True if the number is positive (greater than 0), and False otherwise. Args: ...
code_exercise_27k
1,724
Write a Python function named `is_negative` that takes a parameter `num` and returns `True` if the number is negative (less than 0), and `False` otherwise. The function should handle both integers and floating-point numbers. The code should start with: ```python def is_negative(num: int | float) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_negative(num: int | float) -> bool: """ Determines if the given number is negative. This function takes a number as input and returns True if the number is negative (less than 0), and False otherwise. Args: ...
code_exercise_27k
1,725
Write a Python function named `is_odd` that takes a parameter `num` and returns `True` if the number is odd, and `False` otherwise. The function should be efficient and straightforward, leveraging basic arithmetic operations. The code should start with: ```python def is_odd(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_odd(num: int) -> bool: """ Determines if a given number is odd. Args: num (int): The number to check for oddness. Returns: bool: True if the number is odd, False otherwise. """ return num...
code_exercise_27k
1,726
Write a Python function named `is_even` that takes a parameter `num` and returns `True` if the number is even, and `False` otherwise. The function should be able to handle both positive and negative integers. The code should start with: ```python def is_even(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_even(num: int) -> bool: """ Determines if a given number is even. Args: num (int): The number to check for evenness. Returns: bool: True if the number is even, False otherwise. """ # Chec...
code_exercise_27k
1,727
Write a Python function named `find_maximum` that takes three parameters, `num1`, `num2`, and `num3`, and returns the maximum of the three numbers. The function should be implemented without using Python's built-in `max` function. Instead, use conditional statements to determine the maximum value. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python def find_maximum(num1: int, num2: int, num3: int) -> int: """ This function takes three numbers as input and returns the maximum of the three numbers. Parameters: num1 (int): The first number. num2 (int): The second...
code_exercise_27k
1,728
Write a Python function named `find_minimum` that takes three parameters, `num1`, `num2`, and `num3`, and returns the minimum of the three numbers. The function should handle both integer and floating-point numbers. The code should start with: ```python def find_minimum(num1: int | float, num2: int | float, num3: int |...
Here is the Python code to solve the given problem in the markdown block: ```python def find_minimum(num1: int | float, num2: int | float, num3: int | float) -> int | float: """ This function takes three numbers as input and returns the minimum of the three numbers. Parameters: num1 (int or float): The...
code_exercise_27k
1,729
Write a Python function named `is_prime` that takes a parameter `num` and returns `True` if the number is prime, and `False` otherwise. Assume that the input number is greater than 1. The function should be efficient and handle large numbers. The code should start with: ```python def is_prime(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(num: int) -> bool: """ Determines if a given number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. """ # ...
code_exercise_27k
1,730
Write a Python function named `find_factorial` that takes a parameter `num` and returns the factorial of the number. The function should handle both positive integers and the special case where `num` is 0, returning 1 as the factorial of 0. The function should also handle negative integers by returning `None`, indicati...
Here is the Python code to solve the given problem in the markdown block: ```python def find_factorial(num: int) -> int: """ Calculate the factorial of a given number. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. The factorial of 0 is define...
code_exercise_27k
1,731
Write a Python function named `find_average` that takes a list of numbers as a parameter and returns the average of the numbers. If the list is empty, the function should return 0. The function should handle both integer and floating-point numbers. The code should start with: ```python from typing import List def find...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_average(numbers: List[float]) -> float: """ Calculate the average of a list of numbers. Args: numbers (List[float]): A list of numbers (integers or floating-point numbers). Ret...
code_exercise_27k
1,732
Write a Python function named `find_square_root` that takes a parameter `num` and returns the square root of the number. The function should handle both positive and negative numbers, returning the principal square root for positive numbers and the principal square root of the absolute value with an imaginary unit for ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def find_square_root(num: float) -> float: """ Calculate the square root of a given number. For positive numbers, the function returns the principal square root. For negative numbers, the function returns t...
code_exercise_27k
1,735
Write a Python function named `find_gcd` that takes two parameters, `num1` and `num2`, and returns the greatest common divisor (GCD) of the two numbers using the Euclidean algorithm. The function should handle both positive and negative integers. The code should start with: ```python def find_gcd(num1: int, num2: int) ...
Here is the Python code to solve the given problem in the markdown block: ```python def find_gcd(num1: int, num2: int) -> int: """ Calculate the greatest common divisor (GCD) of two numbers using the Euclidean algorithm. Args: num1 (int): The first number. num2 (int): The second number. ...
code_exercise_27k
1,739
Write a Python function named `generate_fibonacci` that takes a parameter `n` and returns a list containing the first `n` Fibonacci numbers. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the previous two numbers. The function should handle edge cases such as `n` being 0 or negativ...
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. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the previous two numbers...
code_exercise_27k
1,740
Write a Python function to find all prime numbers up to a given number `num` using the Sieve of Eratosthenes algorithm. The function should return a list of prime numbers. The code should start with: ```python from typing import List def find_prime_numbers(num: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_prime_numbers(num: int) -> List[int]: """ Find all prime numbers up to a given number using the Sieve of Eratosthenes algorithm. Args: num (int): The upper limit to find prime numbe...
code_exercise_27k
1,741
Write a Python function named `filter_positive_numbers` that takes a list of integers as a parameter and returns a new list containing only the positive integers from the original list. The function should handle an empty list and return an empty list in that case. The function should also handle lists with non-integer...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_positive_numbers(numbers: List[int]) -> List[int]: """ Filters and returns a list of positive integers from the given list. Args: numbers (List[int]): A list of integers. Ret...
code_exercise_27k
1,742
Write a Python function named `find_negative_numbers` that takes a list of numbers as a parameter and returns a new list containing only the negative numbers from the original list. The function should be efficient and handle various edge cases, such as an empty list or a list with no negative numbers. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_negative_numbers(numbers: List[int]) -> List[int]: """ Returns a new list containing only the negative numbers from the given list of numbers. Args: numbers (List[int]): A list of i...
code_exercise_27k
1,743
Write a Python function named `find_sum_with_accumulator` that takes a list of numbers as a parameter and returns the sum of all the numbers in the list. The function should use an accumulator to iteratively sum the numbers, rather than using Python's built-in `sum` function. 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 def find_sum_with_accumulator(numbers: List[int]) -> int: """ Calculate the sum of all numbers in the given list using an accumulator. Args: numbers (List[int]): A list of integers to be sum...
code_exercise_27k
1,744
Write a Python function named `find_product` that takes a list of numbers as a parameter and returns the product of all the numbers in the list. The function should handle both integer and floating-point numbers. The code should start with: ```python from typing import List def find_product(numbers: List[float]) -> fl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_product(numbers: List[float]) -> float: """ Calculate the product of all numbers in the given list. Args: numbers (List[float]): A list of numbers (integers or floats). Returns...
code_exercise_27k
1,745
Write a Python function named `find_average_of_positive_numbers` that takes a list of numbers as a parameter and returns the average of only the positive numbers in the list. If there are no positive numbers, return 0. The function should handle an empty list by returning 0. 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 def find_average_of_positive_numbers(numbers: List[int]) -> float: """ Calculate the average of only the positive numbers in the given list. Args: numbers (List[int]): A list of integers. ...
code_exercise_27k
1,746
Write a Python function named `find_average_of_negative_numbers` that takes a list of numbers as a parameter and returns the average of only the negative numbers in the list. If there are no negative numbers, return 0. The function should handle cases where the input list is empty or contains no negative numbers. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_average_of_negative_numbers(numbers: List[int]) -> float: """ Calculate the average of only the negative numbers in the given list. Args: numbers (List[int]): A list of integers. ...
code_exercise_27k
1,747
Write a Python function named `find_numbers_greater_than` that takes two parameters, `numbers` (a list of numbers) and `threshold` (a number), and returns a new list containing only the numbers greater than the threshold. The function should handle edge cases such as an empty list or a threshold that is greater than al...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_greater_than(numbers: List[int], threshold: int) -> List[int]: """ Returns a new list containing only the numbers from the input list that are greater than the specified threshold. ...
code_exercise_27k
1,748
Write a Python function named `filter_numbers_below_threshold` that takes two parameters, `numbers` (a list of numbers) and `threshold` (a number), and returns a new list containing only the numbers less than the threshold. The function should handle edge cases such as an empty list or a threshold that is not a number....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def filter_numbers_below_threshold(numbers: List[Union[int, float]], threshold: Union[int, float]) -> List[Union[int, float]]: """ Filters a list of numbers and returns a new list containing only ...
code_exercise_27k
1,749
Write a Python function named `find_numbers_between` that takes three parameters: `numbers` (a list of numbers), `lower_threshold` (a number), and `upper_threshold` (a number). The function should return a new list containing only the numbers from the `numbers` list that are between the `lower_threshold` and `upper_thr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def find_numbers_between(numbers: List[Union[int, float]], lower_threshold: Union[int, float], upper_threshold: Union[int, float]) -> List[Union[int, float]]: """ Returns a new list containing onl...
code_exercise_27k
1,752
Write a Python function named `find_numbers_in_range` that takes three parameters: `numbers` (a list of numbers), `lower_range` (a number), and `upper_range` (a number). The function should return a new list containing only the numbers from the `numbers` list that fall within the specified range `[lower_range, upper_ra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_in_range(numbers: List[int], lower_range: int, upper_range: int) -> List[int]: """ Returns a new list containing only the numbers from the input list that fall within the specified range...
code_exercise_27k
1,753
Write a Python function named `find_numbers_not_in_range` that takes three parameters: `numbers` (a list of numbers), `lower_range` (a number), and `upper_range` (a number). The function should return a new list containing only the numbers from the `numbers` list that do not fall within the specified range `[lower_rang...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_not_in_range(numbers: List[int], lower_range: int, upper_range: int) -> List[int]: """ Returns a new list containing only the numbers from the input list that do not fall within the spec...
code_exercise_27k
1,755
Write a Python function named `find_numbers_without_digit` that takes two parameters, `numbers` (a list of integers) and `digit` (an integer between 0 and 9), and returns a new list containing only the numbers that do not contain the specified digit. The function should handle edge cases such as an empty list or a digi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_without_digit(numbers: List[int], digit: int) -> List[int]: """ Returns a new list containing only the numbers from the input list that do not contain the specified digit. Args: ...
code_exercise_27k
1,760
Write a Python function named `find_numbers_with_digit_count` that takes two parameters, `numbers` (a list of integers) and `digit_count` (an integer), and returns a new list containing only the numbers that have the specified count of digits. The function should handle both positive and negative numbers, and the digit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_with_digit_count(numbers: List[int], digit_count: int) -> List[int]: """ Returns a list of numbers from the input list that have the specified count of digits. Args: numbers...
code_exercise_27k
1,762
Write a Python function named `find_numbers_with_unique_digits` that takes a parameter `numbers` (a list of integers) and returns a new list containing only the numbers that have unique digits (no repeated digits). The function should ensure that the digits in each number are distinct. 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 def find_numbers_with_unique_digits(numbers: List[int]) -> List[int]: """ Returns a new list containing only the numbers that have unique digits (no repeated digits). Args: numbers (List[int...
code_exercise_27k
1,764
Write a Python function named `find_numbers_with_consecutive_digits` that takes a parameter `numbers` (a list of integers) and returns a new list containing only the numbers that have consecutive digits. Consecutive digits are defined as digits that are either in increasing order (e.g., 123) or decreasing order (e.g., ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_with_consecutive_digits(numbers: List[int]) -> List[int]: """ Returns a new list containing only the numbers that have consecutive digits. Consecutive digits are defined as digits t...
code_exercise_27k
1,782
Write a Python function named `find_numbers_with_digit_pattern` that takes two parameters: `numbers` (a list of integers) and `pattern` (a string representing a digit pattern). The function should return a new list containing only the numbers from the input list whose digits include the specified pattern. The code sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_with_digit_pattern(numbers: List[int], pattern: str) -> List[int]: """ Returns a list of numbers from the input list whose digits include the specified pattern. Args: number...
code_exercise_27k
1,783
Write a Python function named `find_numbers_without_digit_pattern` that takes two parameters: `numbers` (a list of integers) and `pattern` (a string representing a digit pattern). The function should return a new list containing only the numbers whose digits do not contain the specified pattern. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_without_digit_pattern(numbers: List[int], pattern: str) -> List[int]: """ Returns a list of numbers whose digits do not contain the specified pattern. Args: numbers (List[in...
code_exercise_27k
1,784
Write a Python function named `find_numbers_with_digit_sequence` that takes two parameters: `numbers` (a list of integers) and `sequence` (a string representing a digit sequence). The function should return a new list containing only the numbers from the input list whose digits contain the specified sequence. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_with_digit_sequence(numbers: List[int], sequence: str) -> List[int]: """ Returns a list of numbers from the input list whose digits contain the specified sequence. Args: num...
code_exercise_27k
1,785
Write a Python function named `find_numbers_without_digit_sequence` that takes two parameters: `numbers` (a list of integers) and `sequence` (a string representing a digit sequence). The function should return a new list containing only the numbers from the input list whose digits do not form the specified sequence. T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_without_digit_sequence(numbers: List[int], sequence: str) -> List[int]: """ Returns a list of numbers from the input list whose digits do not form the specified sequence. Args: ...
code_exercise_27k
1,787
Write a Python function named `find_numbers_without_digit_repetition` that takes two parameters: `numbers` (a list of integers) and `repetition_count` (an integer). The function should return a new list containing only the numbers from the input list whose digits do not repeat a specific number of times as specified by...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_numbers_without_digit_repetition(numbers: List[int], repetition_count: int) -> List[int]: """ Returns a list of numbers from the input list whose digits do not repeat a specific number of times....
code_exercise_27k
1,788
Write a Python function to determine if a given integer is even. The function should return `True` if the number is even and `False` otherwise. The function should handle both positive and negative integers. The code should start with: ```python def is_even(number: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_even(number: int) -> bool: """ Determine if a given integer is even. Args: number (int): The integer to be checked. Returns: bool: True if the number is even, False otherwise. """ # Check...
code_exercise_27k
1,790
Write a Python function to count the number of even numbers in a given list of integers. The function should handle an empty list and return 0 if the list is empty. The function should also handle lists with both positive and negative integers. The code should start with: ```python from typing import List def count_ev...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def count_even_numbers(numbers: List[int]) -> int: """ Count the number of even numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: in...
code_exercise_27k
1,791
Write a Python function to count the number of odd numbers in a given list of integers. The function should handle an empty list and return 0 in that case. The function should also handle lists with both positive and negative integers. The code should start with: ```python from typing import List def count_odd_numbers...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def count_odd_numbers(numbers: List[int]) -> int: """ Count the number of odd numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: int:...
code_exercise_27k
1,792
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should handle an empty list and return 0 in that case. The function should also handle lists with no even numbers and return 0 in that case. The function should be named `sum_even` and should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_even(numbers: List[int]) -> int: """ Calculate the sum of all even numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: int: The ...
code_exercise_27k
1,793
Write a Python function called `sum_odd` that takes a list of integers as input and returns the sum of all odd numbers in the list. The function should handle an empty list by returning 0. The code should start with: ```python from typing import List def sum_odd(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_odd(numbers: List[int]) -> int: """ Calculate the sum of all odd numbers in a given list. Args: numbers (List[int]): A list of integers. Returns: int: The sum of all odd...
code_exercise_27k
1,794
Write a Python function to filter out and return a new list containing only the even numbers from a given list of integers. The function should handle an empty list and return an empty list in that case. The function should also handle lists with no even numbers and return an empty list in that case. The function shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_even_numbers(numbers: List[int]) -> List[int]: """ Filters and returns a new list containing only the even numbers from the given list of integers. Args: numbers (List[int]): A list...
code_exercise_27k
1,795
Write a Python function to filter out and return a new list containing only the odd numbers from a given list of integers. The function should handle an empty list and return an empty list in that case. The function should also handle lists with both positive and negative integers. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_odd_numbers(numbers: List[int]) -> List[int]: """ Filters out and returns a new list containing only the odd numbers from a given list of integers. Args: numbers (List[int]): A list...
code_exercise_27k
1,796
Write a Python function to determine if a given number is a prime number. The function should return `True` if the number is prime and `False` otherwise. The function should handle edge cases such as negative numbers, 0, and 1, which are not prime numbers. The function should also be efficient by checking divisibility ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(number: int) -> bool: """ Determine if a given number is a prime number. Args: number (int): The number to be checked for primality. Returns: bool: True if the number is prime,...
code_exercise_27k
1,797
Write a Python function called `find_primes` that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. The function should use a helper function `is_prime` to determine if a number is prime. The code should start with: ```python from typing import List impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def is_prime(num: int) -> bool: """ Check if a given number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime,...
code_exercise_27k
1,799
Write a Python function called `find_not_divisible_by` that takes a list of integers and a divisor as input, and returns a new list containing only the numbers from the original list that are not divisible by the divisor. The function should handle edge cases such as an empty list or a divisor of zero. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_not_divisible_by(numbers: List[int], divisor: int) -> List[int]: """ Find and return a new list containing only the numbers from a given list that are not divisible by a specified divisor. ...
code_exercise_27k
1,800
Write a Python function called `find_multiples` that takes a list of integers and a factor as input, and returns a new list containing only the numbers from the original list that are multiples of the factor. The function should handle cases where the input list is empty or the factor is zero. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_multiples(numbers: List[int], factor: int) -> List[int]: """ Find and return a new list containing only the numbers from a given list that are multiples of a specified factor. Args: ...
code_exercise_27k
1,801
Write a Python function called `find_not_multiples` that takes a list of integers and a factor as input, and returns a new list containing only the numbers from the original list that are not multiples of the factor. The function should handle edge cases such as an empty list or a factor of zero. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_not_multiples(numbers: List[int], factor: int) -> List[int]: """ Find and return a new list containing only the numbers from a given list that are not multiples of a specified factor. Args:...
code_exercise_27k
1,802
Write a Python function called `find_divisible_by_all` that takes a list of integers and a list of divisors as input, and returns a new list containing only the numbers from the original list that are divisible by all the divisors. The function should be efficient and handle edge cases such as empty lists and non-integ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_divisible_by_all(numbers: List[int], divisors: List[int]) -> List[int]: """ Find and return a new list containing only the numbers from a given list that are divisible by all the specified divis...
code_exercise_27k
1,805
Write a Python function to find the greatest common divisor (GCD) of two integers using the Euclidean algorithm. The function should handle both positive and negative integers, and should return the absolute value of the GCD. The code should start with: ```python def find_gcd(num1: int, num2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_gcd(num1: int, num2: int) -> int: """ Find and return the greatest common divisor (GCD) of two given numbers using the Euclidean algorithm. Args: num1 (int): The first number. num2 (int): The second...
code_exercise_27k
1,807
Write a Python function called `find_sum_even_odd` that takes a list of integers as input and returns a tuple containing the sum of even numbers and the sum of odd numbers in the list, in that order. The function should handle an empty list by returning `(0, 0)`. 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, Tuple def find_sum_even_odd(numbers: List[int]) -> Tuple[int, int]: """ Calculate the sum of even numbers and the sum of odd numbers in a given list. Args: numbers (List[int]): A list of in...
code_exercise_27k
1,808
Write a Python function to calculate the difference between the sum of even numbers and the sum of odd numbers in a given list of integers. The function should handle an empty list by returning 0. The code should start with: ```python from typing import List def find_difference_even_odd(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_difference_even_odd(numbers: List[int]) -> int: """ Calculate the difference between the sum of even numbers and the sum of odd numbers in a given list. Args: numbers (List[int]): A...
code_exercise_27k
1,811
Write a Python function to find the maximum even number in a given list of integers. If there are no even numbers in the list, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no even numbers. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_max_even(numbers: List[int]) -> Optional[int]: """ Find and return the maximum even number in a given list of integers. If there are no even numbers, return None. Args: ...
code_exercise_27k
1,812
Write a Python function to find the maximum odd number in a given list of integers. If the list contains no odd numbers, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with only even numbers. The code should start with: ```python from typing im...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_max_odd(numbers: List[int]) -> Optional[int]: """ Find and return the maximum odd number in a given list of integers. If there are no odd numbers, return None. Args: numbe...
code_exercise_27k
1,813
Write a Python function called `find_min_even` that takes a list of integers as input and returns the minimum even number in the list. If there are no even numbers, return `None`. The function should handle an empty list by returning `None`. The code should start with: ```python from typing import List, Optional def f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_min_even(numbers: List[int]) -> Optional[int]: """ Find and return the minimum even number in a given list of integers. If there are no even numbers, return None. Args: ...
code_exercise_27k
1,814
Write a Python function called `find_min_odd` that takes a list of integers as input and returns the minimum odd number in the list. If there are no odd numbers, return `None`. The function should handle cases where the input list is empty or contains only even numbers. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_min_odd(numbers: List[int]) -> Optional[int]: """ Find and return the minimum odd number in a given list of integers. If there are no odd numbers, return None. Args: numbe...
code_exercise_27k
1,821
Write a Python function to find all the prime factors of a given integer. The function should return a list of these prime factors in ascending order. The code should start with: ```python from typing import List def find_prime_factors(number: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_prime_factors(number: int) -> List[int]: """ Find and return a list of all the prime factors of a given number. Args: number (int): The number to find the prime factors of. Ret...
code_exercise_27k
1,822
Write a Python function to determine if a given integer is a perfect square. The function should return `True` if the number is a perfect square and `False` otherwise. The function should handle both positive and negative integers. The code should start with: ```python def is_perfect_square(number: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_perfect_square(number: int) -> bool: """ Determine if a given integer is a perfect square. Args: number (int): The integer to be checked. Returns: bool: True if the number is a perfect square, Fa...
code_exercise_27k
1,824
Write a Python function to determine if a given integer is a power of two. The function should return `True` if the number is a power of two, and `False` otherwise. The function should handle edge cases such as non-positive integers and should be efficient in its computation. The code should start with: ```python def ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_power_of_two(number: int) -> bool: """ Determine if a given integer is a power of two. Args: number (int): The integer to be checked. Returns: bool: True if the number is a power of two, False ot...
code_exercise_27k
1,825
Write a Python function called `find_powers_of_two` that takes a list of integers as input and returns a new list containing only the numbers that are powers of two from the original list. The function should use a helper function `is_power_of_two` to determine if a number is a power of two. The starter code should st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_powers_of_two(numbers: List[int]) -> List[int]: """ Find and return a new list containing only the numbers that are powers of two from a given list. Args: numbers (List[int]): A lis...
code_exercise_27k
1,826
Write a Python function to generate the first n Fibonacci numbers. The function should handle edge cases such as when n is 0 or 1. The code should start with: ```python from typing import List def find_fibonacci(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_fibonacci(n: int) -> List[int]: """ Generate and return a list of the first n Fibonacci numbers. Args: n (int): The number of Fibonacci numbers to generate. Returns: ...
code_exercise_27k
1,827
Write a Python function to calculate the factorial of a given non-negative integer using an iterative approach. The function should handle edge cases such as zero and large numbers efficiently. The code should start with: ```python def find_factorial(number: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_factorial(number: int) -> int: """ Calculate and return the factorial of a given non-negative integer. Args: number (int): The non-negative integer to calculate the factorial of. Returns: int: ...
code_exercise_27k
1,828
Write a Python function called `find_factorial_list` that takes a list of integers as input and returns a new list containing the factorial of each number in the original list. The function should handle both positive and non-positive integers appropriately. For non-positive integers, the factorial should be defined as...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_factorial_list(numbers: List[int]) -> List[int]: """ Calculate and return a new list containing the factorial of each number in a given list. Parameters: numbers (List[int]): A list...
code_exercise_27k
1,829
Write a Python function called `find_sum_digits` that takes an integer as input and returns the sum of its digits. The function should handle both positive and negative integers. The code should start with: ```python def find_sum_digits(number: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_sum_digits(number: int) -> int: """ Calculate and return the sum of the digits of a given number. Args: number (int): The number to calculate the sum of its digits. Returns: int: The sum of the...
code_exercise_27k
1,831
Write a Python function to find the reverse of a given integer. The function should handle both positive and negative integers. If the input number is negative, the function should return the reverse of the absolute value of the number with a negative sign. The function should also handle edge cases such as zero and si...
Here is the Python code to solve the given problem in the markdown block: ```python def find_reverse_number(number: int) -> int: """ Calculate and return the reverse of a given integer. Parameters: number (int): The integer to calculate the reverse of. Returns: int: The reverse of the ...
code_exercise_27k
1,832
Write a Python function called `find_reverse_list` that takes a list of integers as input and returns a new list containing the reverse of each number in the original list. The function should handle both positive and negative integers correctly. The reversed number should maintain the sign of the original number. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_reverse_list(numbers: List[int]) -> List[int]: """ Calculate and return a new list containing the reverse of each number in a given list. Parameters: numbers (List[int]): A list of ...
code_exercise_27k
1,833
Write a Python function called `find_palindrome` that takes an integer as input and returns `True` if the number is a palindrome, and `False` otherwise. A palindrome number is a number that remains the same when its digits are reversed. The function should handle both positive and negative integers. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python def find_palindrome(number: int) -> bool: """ Check if a given number is a palindrome. Parameters: number (int): The number to be checked. Returns: bool: True if the number is a palindrome, False otherwise. ...
code_exercise_27k
1,835
Write a Python function to convert a given integer to its binary representation as a string. The function should handle both positive and negative integers, and should return the binary representation without the '0b' prefix used in Python's built-in `bin()` function. Additionally, the function should handle the specia...
Here is the Python code to solve the given problem in the markdown block: ```python def find_binary(number: int) -> str: """ Convert a given integer to its binary representation as a string. Args: number (int): The integer to be converted to binary. Returns: str: The binary representat...
code_exercise_27k
1,837
Write a Python function to convert a given integer to its hexadecimal representation as a string. The function should handle both positive and negative integers, and the hexadecimal string should be prefixed with '0x' for positive numbers and '-0x' for negative numbers. The function should also handle the special case ...
Here is the Python code to solve the given problem in the markdown block: ```python def find_hexadecimal(number: int) -> str: """ Convert a given integer to its hexadecimal representation as a string. Parameters: number (int): The integer to be converted. Returns: str: The hexadecimal represen...
code_exercise_27k
1,841
Write a Python function to convert a binary number represented as a string to its decimal (base-10) representation. The function should handle binary strings of any length, including those with leading zeros. The function should start with: ```python def binary_to_decimal(binary_str: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def binary_to_decimal(binary_str: str) -> int: """ Convert a given binary number (in the form of a string) to its decimal representation as an integer. Args: binary_str (str): The binary number to be converted, repr...
code_exercise_27k
1,843
Write a Python function to convert a given decimal number to its binary representation as a string. The function should handle both positive and negative integers, and should return the binary representation in a consistent format (e.g., always prefixed with '0b' for positive numbers and '-0b' for negative numbers). T...
Here is the Python code to solve the given problem in the markdown block: ```python def decimal_to_binary(decimal: int) -> str: """ Convert a given decimal number to its binary representation as a string. The binary representation will include the '0b' prefix for positive numbers and '-0b' prefix for n...
code_exercise_27k
1,846
Write a Python function called `find_hexadecimal_to_decimal_list` that takes a list of hexadecimal numbers (in the form of strings) as input and returns a new list containing the decimal representation of each hexadecimal number as integers. The function should use Python's built-in `int` function with base 16 to perfo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_hexadecimal_to_decimal_list(hexadecimal_list: List[str]) -> List[int]: """ Convert each hexadecimal number in a given list (in the form of strings) to its decimal representation as integers and ...
code_exercise_27k
1,847
Write a Python function to convert an octal number (represented as a string) to its decimal representation. The function should handle octal numbers with valid digits (0-7) and return the corresponding decimal integer. The function should start with: ```python def octal_to_decimal(octal: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def octal_to_decimal(octal: str) -> int: """ Convert a given octal number (in the form of a string) to its decimal representation as an integer. Args: octal (str): The octal number to be converted. It should contain...
code_exercise_27k
1,849
Write a Python function to count the number of even numbers in a given list of integers. The function should handle an empty list and return 0 in that case. The function should also handle lists with both positive and negative integers. The code should start with: ```python from typing import List def find_even_count(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_even_count(numbers: List[int]) -> int: """ Counts the number of even numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: int: T...
code_exercise_27k
1,850
Write a Python function to count the number of odd numbers in a given list of integers. The function should be named `count_odds` and should take a single parameter, `numbers`, which is a list of integers. The function should return an integer representing the count of odd numbers in the list. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_odds(numbers: List[int]) -> int: """ Counts the number of odd numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: int: The cou...
code_exercise_27k
1,851
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should handle an empty list and return 0 in that case. The function should also handle lists with no even numbers and return 0 in that case. The code should start with: ```python from typing import List def find_...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_sum_even_numbers(numbers: List[int]) -> int: """ Calculate and return the sum of all even numbers in a given list. Args: numbers (List[int]): A list of integers. Returns: ...
code_exercise_27k
1,852
Write a Python function to calculate the sum of all odd numbers in a given list of integers. The function should handle an empty list and return 0 in that case. The function should start with: ```python from typing import List def find_sum_odd_numbers(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_sum_odd_numbers(numbers: List[int]) -> int: """ Calculate and return the sum of all odd numbers in a given list. Args: numbers (List[int]): A list of integers. Returns: ...
code_exercise_27k
1,855
Write a Python function to find the maximum even number in a given list of integers. If there are no even numbers in the list, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no even numbers. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_max_even_number(numbers: List[int]) -> Optional[int]: """ Find and return the maximum even number in a given list of integers. If there are no even numbers, return None. Args: ...
code_exercise_27k
1,856
Write a Python function to find the maximum odd number in a given list of integers. If the list contains no odd numbers, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no odd numbers. 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, Optional def find_max_odd_number(numbers: List[int]) -> Optional[int]: """ Find and return the maximum odd number in a given list of integers. If there are no odd numbers, return None. Args: ...
code_exercise_27k
1,857
Write a Python function to find the minimum even number in a given list of integers. If there are no even numbers in the list, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no even numbers. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_min_even_number(numbers: List[int]) -> Optional[int]: """ Find and return the minimum even number in a given list of integers. If there are no even numbers, return None. Args: ...
code_exercise_27k
1,858
Write a Python function to find the minimum odd number in a given list of integers. If there are no odd numbers in the list, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no odd numbers. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_min_odd_number(numbers: List[int]) -> Optional[int]: """ Find and return the minimum odd number in a given list of integers. If there are no odd numbers, return None. Args: ...
code_exercise_27k
1,864
Write a Python function to find all the factors of a given integer. The function should return a list of all the factors, including 1 and the number itself. The code should start with: ```python from typing import List def find_factors_number(number: 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 find_factors_number(number: int) -> List[int]: """ Find and return a list of all the factors of a given number. Args: number (int): The number to find the factors of. Re...
code_exercise_27k
1,865
Write a Python function to find all the prime factors of a given integer. The function should return a list of these prime factors in ascending order. The function should handle both positive and negative integers, treating negative integers as their absolute values. The code should start with: ```python from typing im...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_prime_factors(number: int) -> List[int]: """ Find and return a list of all the prime factors of a given number. Args: number (int): The number to find the prime factors of. Ret...