source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 2,111 | Write a Python function to find the binary representation of a given non-negative integer. The function should return the binary representation as a string without the '0b' prefix that Python's `bin()` function includes. The function should handle edge cases such as zero and large integers.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_binary_representation(num: int) -> str:
"""
Returns the binary representation of a non-negative integer as a string without the '0b' prefix.
Args:
num (int): The non-negative integer to convert to binary.
... |
code_exercise_27k | 2,112 | Write a Python function named `find_hexadecimal_representation` that takes one parameter, `num`, and returns the hexadecimal representation of the number as a string. The function should handle both positive and negative integers. The hexadecimal string should be prefixed with '0x' for positive numbers and '-0x' for ne... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_hexadecimal_representation(num: int) -> str:
"""
Converts an integer to its hexadecimal representation as a string.
Parameters:
num (int): The integer to be converted.
Returns:
str: The hexadecimal rep... |
code_exercise_27k | 2,115 | Write a Python function named `find_cube` that takes one parameter, `num`, and returns the cube of the number. The function should handle both integer and floating-point inputs. The code should start with:
```python
def find_cube(num: int | float) -> int | float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_cube(num: int | float) -> int | float:
"""
Calculate the cube of a given number.
Args:
num (int | float): The number to be cubed.
Returns:
int | float: The cube of the input number.
"""
... |
code_exercise_27k | 2,116 | Write a Python function to calculate the square root of a given number. If the number is negative, the function should return `None`. The function should be named `find_square_root` and should take one parameter, `num`. The code should start with:
```python
import math
def find_square_root(num: float) -> float:
```
| 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. If the number is negative, return None.
Args:
num (float): The number for which to calculate the square root.
... |
code_exercise_27k | 2,118 | Write a Python function to calculate the factorial of a given non-negative integer using recursion. The factorial of a non-negative integer \( n \) is the product of all positive integers less than or equal to \( n \). The function should handle edge cases such as negative input by returning `None`.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_factorial_recursive(n: int) -> int:
"""
Calculate the factorial of a given non-negative integer using recursion.
Parameters:
n (int): The non-negative integer for which to calculate the factorial.
Returns:... |
code_exercise_27k | 2,121 | Write a Python function to calculate the sum of the first `n` natural numbers. The function should handle edge cases such as when `n` is less than or equal to 0 by returning `None`. The function should be named `find_sum_of_natural_numbers` and should start with:
```python
def find_sum_of_natural_numbers(n: int) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_natural_numbers(n: int) -> int:
"""
Calculate the sum of the first 'n' natural numbers.
Parameters:
n (int): The number of natural numbers to sum.
Returns:
int: The sum of the first 'n' natural ... |
code_exercise_27k | 2,122 | Write a Python function named `find_sum_of_even_numbers` that takes one parameter, `n`, and returns the sum of the first `n` even numbers. The function should handle edge cases such as when `n` is less than or equal to 0 by returning `None`. The code should start with:
```python
def find_sum_of_even_numbers(n: int) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_even_numbers(n: int) -> int:
"""
Calculate the sum of the first 'n' even numbers.
Args:
n (int): The number of even numbers to sum.
Returns:
int: The sum of the first 'n' even numbers.
... |
code_exercise_27k | 2,123 | Write a Python function named `find_sum_of_odd_numbers` that takes one parameter, `n`, and returns the sum of the first `n` odd numbers. The function should handle edge cases such as non-positive integers by returning `None`. The code should start with:
```python
def find_sum_of_odd_numbers(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_odd_numbers(n: int) -> int:
"""
Calculate the sum of the first n odd numbers.
Args:
n (int): The number of odd numbers to sum.
Returns:
int: The sum of the first n odd numbers. If n is l... |
code_exercise_27k | 2,124 | Write a Python function named `find_sum_of_squares` that takes one parameter, `n`, and returns the sum of the squares of the first `n` natural numbers. The function should handle edge cases such as when `n` is less than or equal to 0 by returning `None`. The function should also be efficient and use a mathematical form... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_squares(n: int) -> int:
"""
Calculate the sum of the squares of the first 'n' natural numbers.
Args:
n (int): The number of natural numbers to consider.
Returns:
int: The sum of the squa... |
code_exercise_27k | 2,125 | Write a Python function named `find_sum_of_cubes` that takes one parameter, `n`, and returns the sum of the cubes of the first `n` natural numbers. The function should handle edge cases where `n` is less than or equal to 0 by returning `None`. The function should also be efficient and use a mathematical formula to comp... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_cubes(n: int) -> int:
"""
Calculate the sum of the cubes of the first 'n' natural numbers.
Args:
n (int): The number of natural numbers to consider.
Returns:
int: The sum of the cubes of... |
code_exercise_27k | 2,127 | Write a Python function named `find_number_of_digits` that takes one parameter, `num`, and returns the number of digits in the number. If the number is negative, ignore the negative sign. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def find_numb... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_number_of_digits(num: int) -> int:
"""
Returns the number of digits in the given integer. If the number is negative, the negative sign is ignored.
Args:
num (int): The integer whose digits are to be counted... |
code_exercise_27k | 2,128 | Write a Python function named `find_nth_digit` that takes two parameters, `num` and `n`, and returns the nth digit of the number. If the number is negative, ignore the negative sign. If the nth digit does not exist (i.e., `n` is less than 1 or greater than the number of digits in `num`), return `None`.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_nth_digit(num: int, n: int) -> int:
"""
Returns the nth digit of the given number. If the number is negative, the negative sign is ignored.
If the nth digit does not exist, returns None.
Args:
num (int)... |
code_exercise_27k | 2,129 | Write a Python function named `find_number_of_occurrences` that takes two parameters, `num` and `digit`, and returns the number of occurrences of the digit in the number. The function should handle both positive and negative integers for `num` and should ensure that `digit` is a single digit (0-9). If `digit` is not a ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_number_of_occurrences(num: int, digit: int) -> int:
"""
Counts the number of occurrences of a given digit in a number.
Args:
num (int): The number in which to count the digit occurrences.
digit (int... |
code_exercise_27k | 2,132 | Write a Python function named `find_sum_of_primes` that takes one parameter, `n`, and returns the sum of the first `n` prime numbers. The function should be efficient and correctly handle edge cases such as `n` being 0 or a negative number.
The code should start with:
```python
def find_sum_of_primes(n: int) -> int:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_primes(n: int) -> int:
"""
Calculate the sum of the first 'n' prime numbers.
Args:
n (int): The number of prime numbers to consider.
Returns:
int: The sum of the first 'n' prime numbers.... |
code_exercise_27k | 2,143 | Write a Python function named `find_sum_of_digits_tail_recursive` that takes one parameter, `num`, and returns the sum of the digits in the number using tail recursion. If the number is negative, ignore the negative sign. The function should be implemented in a way that avoids stack overflow for large numbers by using ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_digits_tail_recursive(num: int) -> int:
"""
Calculate the sum of the digits of a number using tail recursion.
Args:
num (int): The number whose digits' sum is to be calculated. If negative, the negat... |
code_exercise_27k | 2,146 | Write a Python function named `find_nth_digit_tail_recursive` that takes two parameters, `num` and `n`, and returns the nth digit of the number using tail recursion. If the number is negative, ignore the negative sign. If the nth digit does not exist, return `None`. The function should be implemented using tail recursi... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_nth_digit_tail_recursive(num: int, n: int) -> int:
"""
Returns the nth digit of the given number using tail recursion.
Args:
num (int): The number from which to extract the nth digit.
n (int): The p... |
code_exercise_27k | 2,149 | Write a Python function named `find_sum_of_digits_recursive` that takes one parameter, `num`, and returns the sum of the digits in the number using recursion. If the number is negative, ignore the negative sign.
The code should start with:
```python
def find_sum_of_digits_recursive(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_digits_recursive(num: int) -> int:
"""
Calculate the sum of the digits in a given number using recursion.
Args:
num (int): The number whose digits' sum is to be calculated.
Returns:
int:... |
code_exercise_27k | 2,150 | Write a Python function named `find_product_of_digits_recursive` that takes one parameter, `num`, and returns the product of the digits in the number using recursion. If the number is negative, ignore the negative sign. The function should start with:
```python
def find_product_of_digits_recursive(num: int) -> int:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_product_of_digits_recursive(num: int) -> int:
"""
Calculate the product of the digits in the given number using recursion.
Args:
num (int): The number whose digits' product is to be calculated.
Returns... |
code_exercise_27k | 2,153 | Write a Python function named `find_number_of_occurrences_iterative` that takes two parameters, `num` and `digit`, and returns the number of occurrences of the `digit` in the `num` using iteration. The function should handle both positive and negative integers for `num` and should only consider the absolute value of `n... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_number_of_occurrences_iterative(num: int, digit: int) -> int:
"""
Counts the number of occurrences of a given digit in a number using iteration.
Args:
num (int): The number in which to count the occurrences... |
code_exercise_27k | 2,157 | Write a Python function named `multiplication` that takes two numbers as input and returns their product. The function should handle both integer and floating-point numbers. Additionally, the function should be able to handle special cases such as multiplying by zero or one, and should return the correct product for th... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiplication(num1: float, num2: float) -> float:
"""
Function to perform multiplication of two numbers.
Parameters:
num1 (float): The first number to be multiplied.
num2 (float): The second number to be multip... |
code_exercise_27k | 2,158 | Write a Python function named `safe_division` that takes two numbers as input and returns their quotient. If the denominator is zero, the function should return `None` instead of raising an error. The function should handle both integer and floating-point inputs.
The code should start with:
```python
def safe_division... | Here is the Python code to solve the given problem in the markdown block:
```python
def safe_division(num1: float, num2: float) -> float:
"""
Perform a safe division of two numbers. If the denominator is zero, return None.
Args:
num1 (float): The numerator.
num2 (float): The denominator.
... |
code_exercise_27k | 2,160 | Write a Python function named `integer_division` that takes two integers as input and returns the quotient after performing integer division. The function should handle the case where the denominator is zero by raising a `ValueError`. The code should start with:
```python
def integer_division(num1: int, num2: int) -> i... | Here is the Python code to solve the given problem in the markdown block:
```python
def integer_division(num1: int, num2: int) -> int:
"""
Perform integer division of two numbers and return the quotient.
Args:
num1 (int): The numerator.
num2 (int): The denominator.
Returns:
int... |
code_exercise_27k | 2,161 | Write a Python function named `modulo` that takes two integers as input and returns the remainder after performing the modulo operation. The function should handle the case where the divisor is zero by raising a `ValueError` with the message "Cannot divide by zero". The code should start with:
```python
def modulo(num1... | Here is the Python code to solve the given problem in the markdown block:
```python
def modulo(num1: int, num2: int) -> int:
"""
Perform the modulo operation on two integers and return the remainder.
Args:
num1 (int): The dividend.
num2 (int): The divisor.
Returns:
int: The rem... |
code_exercise_27k | 2,162 | Write a Python function named `negation` that takes a number as input and returns its negation. The function should handle both integers and floating-point numbers. The code should start with:
```python
def negation(num: int | float) -> int | float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def negation(num: int | float) -> int | float:
"""
Function to perform negation of a number.
Parameters:
num (int or float): Number to be negated.
Returns:
int or float: Negation of the input number.
"""
... |
code_exercise_27k | 2,163 | Write a Python function named `absolute_value` that takes a number as input and returns its absolute value. The function should handle both integers 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:
"""
Calculate the absolute value of a given number.
Args:
num (float): The number to calculate the absolute value of.
Returns:
float: The absolute value of the i... |
code_exercise_27k | 2,164 | Write a Python function named `is_strictly_increasing` that takes a list of numbers as input and returns `True` if the list is strictly increasing (i.e., each element is greater than the previous one), and `False` otherwise. The function should handle lists of integers and floating-point numbers.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_strictly_increasing(numbers: List[float]) -> bool:
"""
Determines if the given list of numbers is strictly increasing.
Args:
numbers (List[float]): A list of numbers to check.
Re... |
code_exercise_27k | 2,165 | Write a Python function named `is_within_range` that takes three numbers as input: `value`, `lower_bound`, and `upper_bound`. The function should return `True` if `value` is within the inclusive range defined by `lower_bound` and `upper_bound`, and `False` otherwise. The function should handle cases where `lower_bound`... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_within_range(value: float, lower_bound: float, upper_bound: float) -> bool:
"""
Check if a value is within a given inclusive range.
Args:
value (float): The value to check.
lower_bound (float): The lo... |
code_exercise_27k | 2,167 | Write a Python function named `not_equal_to` that takes two numbers as input and returns `True` if the first number is not equal to the second number, and `False` otherwise. The function should handle both integers and floating-point numbers. The code should start with:
```python
def not_equal_to(num1: int | float, num... | Here is the Python code to solve the given problem in the markdown block:
```python
def not_equal_to(num1: int | float, num2: int | float) -> bool:
"""
Checks if the first number is not equal to the second number.
Args:
num1 (int | float): The first number to compare.
num2 (int | float): Th... |
code_exercise_27k | 2,168 | Write a Python function named `logical_and` that takes two boolean values as input and returns the result of the logical AND operation between them. The function should handle cases where the inputs are not explicitly boolean values by converting them to boolean using Python's built-in `bool()` function. The function s... | Here is the Python code to solve the given problem in the markdown block:
```python
def logical_and(bool1, bool2):
"""
Function to perform logical AND operation on two boolean values.
Parameters:
bool1 (any): First value to be converted to boolean.
bool2 (any): Second value to be converted to b... |
code_exercise_27k | 2,169 | Write a Python function named `logical_or` that takes two boolean values as input and returns the result of the logical OR operation between them. The function should handle cases where the inputs are not explicitly boolean values by converting them to boolean using Python's built-in `bool()` function. The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def logical_or(value1, value2) -> bool:
"""
Perform a logical OR operation on two values after converting them to boolean.
Args:
value1: The first value to be converted to boolean and used in the OR operation.
... |
code_exercise_27k | 2,174 | Write a Python function named `bitwise_not` that takes an integer as input and returns the result of the bitwise NOT operation on it. The function should handle both positive and negative integers correctly. The code should start with:
```python
def bitwise_not(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def bitwise_not(num: int) -> int:
"""
Perform the bitwise NOT operation on the given integer.
The bitwise NOT operation inverts all the bits of the input integer.
For example, if the input is 5 (binary 101), the bitwise... |
code_exercise_27k | 2,175 | Write a Python function named `left_shift` that takes two integers as input and returns the result of the left shift operation on the first number by the second number of positions. The function should handle cases where the second number is negative by performing a right shift instead of a left shift. The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def left_shift(num1: int, num2: int) -> int:
"""
Perform a left shift operation on an integer by a specified number of positions.
If the number of positions is negative, perform a right shift instead.
Args:
num1... |
code_exercise_27k | 2,177 | Write a Python function named `is_even` that takes an integer as input and returns `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(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 integer is even.
Args:
num (int): The integer to be checked.
Returns:
bool: True if the number is even, False otherwise.
"""
return num %... |
code_exercise_27k | 2,178 | Write a Python function named `is_odd` that takes an integer as input and returns `True` if the number is odd, and `False` otherwise. The function should handle both positive and negative integers. 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 integer is odd.
Args:
num (int): The integer to be checked.
Returns:
bool: True if the number is odd, False otherwise.
"""
# Check if the ... |
code_exercise_27k | 2,179 | Write a Python function named `is_positive` that takes a number as input and returns `True` if the number is positive, and `False` otherwise. The function should handle both integers and floating-point numbers. The code should start with:
```python
def is_positive(num: float) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_positive(num: float) -> bool:
"""
Determines if a given number is positive.
Args:
num (float): The number to be checked.
Returns:
bool: True if the number is positive, False otherwise.
"""
... |
code_exercise_27k | 2,180 | Write a Python function named `is_negative` that takes a number as input and returns `True` if the number is negative, and `False` otherwise. The function should handle both integers and floating-point numbers. The code should start with:
```python
def is_negative(num: float) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_negative(num: float) -> bool:
"""
Determines if a given number is negative.
Args:
num (float): The number to be checked.
Returns:
bool: True if the number is negative, False otherwise.
"""
... |
code_exercise_27k | 2,181 | Write a Python function named `is_zero` that takes a number as input and returns `True` if the number is zero, and `False` otherwise. The function should handle both integer and floating-point numbers. The code should start with:
```python
def is_zero(num: float) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_zero(num: float) -> bool:
"""
Check if the given number is zero.
Args:
num (float): The number to be checked.
Returns:
bool: True if the number is zero, False otherwise.
"""
# Cast the in... |
code_exercise_27k | 2,182 | Write a Python function named `is_divisible` that takes two integers as input and returns `True` if the first number is divisible by the second number, and `False` otherwise. The function should handle cases where the second number is zero by returning `False` to avoid division by zero errors.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible(num1: int, num2: int) -> bool:
"""
Checks if the first number is divisible by the second number.
Args:
num1 (int): The first number.
num2 (int): The second number.
Returns:
bool... |
code_exercise_27k | 2,185 | Write a Python function named `concatenate_strings` that takes two strings as input and returns the concatenation of the two strings. The function should handle cases where either or both of the input strings are `None`. If either string is `None`, it should be treated as an empty string during concatenation.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
def concatenate_strings(str1: str, str2: str) -> str:
"""
Concatenates two strings. If either string is None, it is treated as an empty string.
Args:
str1 (str): The first string to concatenate.
str2 (str): ... |
code_exercise_27k | 2,187 | Write a Python function named `count_occurrences` that takes two strings as input and returns the number of non-overlapping occurrences of the second string within the first string. The function should be case-sensitive and should not use the built-in `count` method. Instead, implement the counting logic manually.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_occurrences(string: str, sub_string: str) -> int:
"""
Counts the number of non-overlapping occurrences of a substring within a string.
Args:
string (str): The main string in which to search for occurrences... |
code_exercise_27k | 2,189 | Write a Python function named `capitalize_string` that takes a string as input and returns the string with the first letter capitalized. If the input string is `None`, the function should return an empty string. The function should handle strings with leading and trailing whitespace by trimming them before capitalizing... | Here is the Python code to solve the given problem in the markdown block:
```python
def capitalize_string(string: str) -> str:
"""
Capitalizes the first letter of a given string. If the input string is None, returns an empty string.
Leading and trailing whitespace is removed before capitalizing the first le... |
code_exercise_27k | 2,190 | Write a Python function named `swap_case` that takes a string as input and returns the string with the case of each letter swapped. The function should handle both uppercase and lowercase letters, and any non-alphabetic characters should remain unchanged. The code should start with:
```python
def swap_case(string: str)... | Here is the Python code to solve the given problem in the markdown block:
```python
def swap_case(string: str) -> str:
"""
Swaps the case of each letter in the given string.
This function takes a string as input and returns a new string where the case of each letter
is swapped. Uppercase letters are co... |
code_exercise_27k | 2,191 | Write a Python function named `join_strings` that takes a list of strings and a delimiter as input and returns a single string by joining the list elements with the delimiter. The function should handle cases where the input list is empty or contains only one element. Additionally, the function should ensure that the d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def join_strings(string_list: List[str], delimiter: str) -> str:
"""
Joins a list of strings into a single string with the specified delimiter.
Args:
string_list (List[str]): List of strings... |
code_exercise_27k | 2,192 | Write a Python function named `find_substring` that takes two strings as input and returns the starting index of the first occurrence of the second string within the first string. If the second string is not found, return -1. The function should be implemented without using Python's built-in `find` method.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_substring(string: str, sub_string: str) -> int:
"""
Finds the starting index of the first occurrence of a sub-string within a string.
Args:
string (str): The main string in which to search for the sub-strin... |
code_exercise_27k | 2,193 | Write a Python function named `remove_whitespace` that takes a string as input and returns the string with all whitespace characters removed. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with:
```python
def remove_whitespace(string: str) ... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace(string: str) -> str:
"""
Removes all whitespace characters from the given string.
Args:
string (str): The input string from which whitespace characters are to be removed.
Returns:
... |
code_exercise_27k | 2,194 | Write a Python function named `replace_substring` that takes three strings as input: the main string, the substring to be replaced, and the replacement substring. The function should return the main string with all occurrences of the substring replaced by the replacement substring. The function should handle cases wher... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_substring(string: str, old_substring: str, new_substring: str) -> str:
"""
Replaces all occurrences of a substring within a string with a new substring.
Args:
string (str): The main string in which the r... |
code_exercise_27k | 2,195 | Write a Python function named `is_alpha` that takes a string as input and returns `True` if all characters in the string are alphabetic (letters), and `False` otherwise. The function should handle edge cases such as empty strings and strings with spaces or special characters. The code should start with:
```python
def i... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_alpha(string: str) -> bool:
"""
Check if all characters in the given string are alphabetic (letters).
Args:
string (str): The string to be checked.
Returns:
bool: True if all characters in the st... |
code_exercise_27k | 2,196 | Write a Python function named `is_digit` that takes a string as input and returns `True` if all characters in the string are digits, and `False` otherwise. The function should handle edge cases such as empty strings and strings with non-digit characters. The code should start with:
```python
def is_digit(string: str) -... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_digit(string: str) -> bool:
"""
Check if all characters in the given string are digits.
Args:
string (str): The string to be checked.
Returns:
bool: True if all characters in the string are digit... |
code_exercise_27k | 2,197 | Write a Python function named `is_alphanumeric` that takes a string as input and returns `True` if all characters in the string are either alphabetic (letters) or digits, and `False` otherwise. The function should handle edge cases such as empty strings and strings with special characters. The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_alphanumeric(string: str) -> bool:
"""
Check if all characters in the given string are either alphabetic (letters) or digits.
Args:
string (str): The string to be checked.
Returns:
bool: True if ... |
code_exercise_27k | 2,202 | Write a Python function named `find_maximum` that takes a list of numbers as input and returns the maximum value from the list. If the list is empty, the function should return `None`. The function should be efficient and handle various types of numeric inputs, including integers and floats.
The code should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_maximum(numbers: List[Union[int, float]]) -> Union[int, float, None]:
"""
Finds the maximum value from a list of numbers.
Args:
numbers (List[Union[int, float]]): A list of n... |
code_exercise_27k | 2,203 | Write a Python function named `find_minimum` that takes a list of numbers as input and returns the minimum value from the list. If the list is empty, the function should return `None`. The function should handle both integers and floating-point numbers. The code should start with:
```python
from typing import List, Uni... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_minimum(numbers: List[Union[int, float]]) -> Union[int, float, None]:
"""
Find the minimum value from a list of numbers.
Args:
numbers (List[Union[int, float]]): A list of nu... |
code_exercise_27k | 2,204 | Write a Python function named `calculate_factorial` that takes a non-negative integer as input and returns the factorial of that number. If the input is negative, return `None`. The function should be implemented using recursion.
The code should start with:
```python
def calculate_factorial(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_factorial(n: int) -> int:
"""
Calculate the factorial of a non-negative integer using recursion.
Parameters:
n (int): Non-negative integer for which the factorial is to be calculated.
Returns:
int... |
code_exercise_27k | 2,207 | Write a Python function named `calculate_area_rectangle` that takes two numbers as input representing the length and width of a rectangle. The function should return the area of the rectangle. The function should handle both integer and floating-point inputs. The code should start with:
```python
def calculate_area_rec... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_area_rectangle(length: float, width: float) -> float:
"""
Calculate the area of a rectangle given its length and width.
Args:
length (float): The length of the rectangle.
width (float): The wid... |
code_exercise_27k | 2,208 | Write a Python function named `calculate_area_rectangle` that takes two numbers as input representing the length and width of a rectangle. The function should return the area of the rectangle. The function should handle cases where the input is not a number by returning `None`.
The code should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_area_rectangle(length, width):
"""
Calculate the area of a rectangle given its length and width.
Args:
length (int or float): The length of the rectangle.
width (int or float): The width of the... |
code_exercise_27k | 2,209 | Write a Python function named `calculate_area_circle` that takes a number as input representing the radius of a circle. The function should return the area of the circle. The function should handle both integer and floating-point inputs. The code should start with:
```python
import math
def calculate_area_circle(radiu... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_area_circle(radius: float) -> float:
"""
Calculate the area of a circle given its radius.
Args:
radius (float): The radius of the circle. Must be a non-negative number.
Returns:
... |
code_exercise_27k | 2,210 | Write a Python function named `calculate_perimeter_rectangle` that takes two numbers as input representing the length and width of a rectangle. The function should return the perimeter of the rectangle. The function should handle both integer and floating-point inputs. The code should start with:
```python
def calculat... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_perimeter_rectangle(length: float, width: float) -> float:
"""
Calculate the perimeter of a rectangle given its length and width.
Args:
length (float): The length of the rectangle.
width (float... |
code_exercise_27k | 2,211 | Write a Python function named `calculate_perimeter_square` that takes a number as input representing the length of a side of a square. The function should return the perimeter of the square. The function should handle both integer and floating-point inputs. The code should start with:
```python
def calculate_perimeter_... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_perimeter_square(side: float) -> float:
"""
Calculate the perimeter of a square given the length of its side.
Args:
side (float): The length of a side of the square.
Returns:
float: The pe... |
code_exercise_27k | 2,217 | Write a Python function named `calculate_percentage` that takes two numbers as input: a partial value and a total value. The function should return the percentage representation of the partial value with respect to the total value. The function should handle cases where the total value is zero by returning `None` to av... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_percentage(partial: float, total: float) -> float:
"""
Calculate the percentage representation of a partial value with respect to a total value.
Args:
partial (float): The partial value.
total ... |
code_exercise_27k | 2,218 | Write a Python function named `calculate_gcd` that takes two positive integers as input and returns their greatest common divisor (GCD) using the Euclidean algorithm. The function should handle the case where one or both of the inputs are zero by returning 0, as the GCD of zero with any number is zero.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_gcd(num1: int, num2: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two non-negative integers using the Euclidean algorithm.
Args:
num1 (int): The first non-negative integer.
n... |
code_exercise_27k | 2,219 | Write a Python function named `calculate_lcm` that takes two positive integers as input and returns their least common multiple (LCM). The function should use the greatest common divisor (GCD) to compute the LCM efficiently. The code should start with:
```python
def calculate_lcm(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_lcm(num1: int, num2: int) -> int:
"""
Calculate the least common multiple (LCM) of two positive integers.
Args:
num1 (int): The first positive integer.
num2 (int): The second positive integer.
... |
code_exercise_27k | 2,220 | Write a Python function named `calculate_binary` that takes a positive integer as input and returns its binary representation as a string. The function should handle the conversion without using Python's built-in `bin()` function. The code should start with:
```python
def calculate_binary(num: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_binary(num: int) -> str:
"""
Calculate the binary representation of a positive integer without using the built-in bin() function.
Args:
num (int): The positive integer to convert to binary.
Return... |
code_exercise_27k | 2,221 | Write a Python function named `calculate_hexadecimal` that takes a positive integer as input and returns its hexadecimal representation as a string. The function should handle the conversion without using Python's built-in `hex()` function. The hexadecimal representation should be in lowercase letters.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_hexadecimal(num: int) -> str:
"""
Calculate the hexadecimal representation of a positive integer without using Python's built-in hex() function.
Args:
num (int): The positive integer to convert to hexa... |
code_exercise_27k | 2,223 | Write a Python function named `calculate_bmi` that takes two numbers as input: weight in kilograms and height in meters. The function should calculate the Body Mass Index (BMI) using the formula `BMI = weight / (height^2)` and return the BMI value rounded to two decimal places. The function should also include input va... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_bmi(weight: float, height: float) -> float:
"""
Calculate the Body Mass Index (BMI) given weight in kilograms and height in meters.
Parameters:
weight (float): Weight in kilograms. Must be a positive numbe... |
code_exercise_27k | 2,224 | Write a Python function named `convert_celsius_to_fahrenheit` that takes a number as input representing a temperature in Celsius. The function should convert the temperature to Fahrenheit using the formula `Fahrenheit = (Celsius * 9/5) + 32` and return the converted temperature rounded to two decimal places.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_celsius_to_fahrenheit(celsius: float) -> float:
"""
Converts a temperature from Celsius to Fahrenheit.
Args:
celsius (float): The temperature in Celsius to be converted.
Returns:
float: The ... |
code_exercise_27k | 2,225 | Write a Python function named `convert_celsius_to_fahrenheit` that takes a number as input representing a temperature in Celsius. The function should convert the temperature to Fahrenheit using the formula Fahrenheit = (Celsius * 9/5) + 32 and return the converted temperature rounded to two decimal places.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_celsius_to_fahrenheit(celsius: float) -> float:
"""
Converts a temperature from Celsius to Fahrenheit.
Args:
celsius (float): The temperature in Celsius to be converted.
Returns:
float: The ... |
code_exercise_27k | 2,226 | Write a Python function named `calculate_age` that takes two integers as input representing the birth year and the current year. The function should calculate the age by subtracting the birth year from the current year and return the age. Additionally, the function should handle cases where the birth year is greater th... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_age(birth_year: int, current_year: int) -> int:
"""
Calculate the age given the birth year and the current year.
Args:
birth_year (int): The year of birth.
current_year (int): The current year.... |
code_exercise_27k | 2,233 | Write a Python function named `calculate_weekday` that takes a string as input representing a date in the format "YYYY-MM-DD". The function should determine the weekday of the given date and return the weekday as a string (e.g., "Monday", "Tuesday", etc.). The function should handle the input date string and return the... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def calculate_weekday(date: str) -> str:
"""
Determine the weekday of a given date in the format "YYYY-MM-DD".
Args:
date (str): A date string in the format "YYYY-MM-DD".
Returns:... |
code_exercise_27k | 2,235 | Write a Python function named `calculate_time_difference` that takes two strings as input representing two times in the format "HH:MM:SS". The function should calculate the time difference between the two times and return the difference as a string in the format "HH:MM:SS". If the second time is earlier than the first ... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime, timedelta
def calculate_time_difference(time1: str, time2: str) -> str:
"""
Calculate the time difference between two times given in the format "HH:MM:SS".
Args:
time1 (str): The ... |
code_exercise_27k | 2,236 | Write a Python function named `calculate_time_in_seconds` that takes a string as input representing a time in the format "HH:MM:SS". The function should calculate the time in seconds and return the result as an integer. The function should handle the input format strictly and ensure that the input string is in the corr... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def calculate_time_in_seconds(time: str) -> int:
"""
Calculate the time in seconds given a time in the format "HH:MM:SS".
Args:
time (str): Time in the format "HH:MM:SS".
Returns:
int: Time i... |
code_exercise_27k | 2,238 | Write a Python function named `calculate_time_in_hours` that takes a string as input representing a time in the format "HH:MM:SS". The function should calculate the time in hours and return the result as a float. The function should handle the input format strictly and ensure that the input string is in the correct for... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def calculate_time_in_hours(time: str) -> float:
"""
Calculate the time in hours given a time in the format "HH:MM:SS".
Args:
time (str): Time in the format "HH:MM:SS".
Returns:
float: Time i... |
code_exercise_27k | 2,244 | Write a Python function named `calculate_time_difference_in_minutes` that takes two strings as input representing two times in the format "HH:MM:SS". The function should calculate the time difference between the two times in minutes and return the difference as an integer. The function should handle cases where the sec... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime, timedelta
def calculate_time_difference_in_minutes(time1: str, time2: str) -> int:
"""
Calculate the time difference between two times in minutes.
Args:
time1 (str): The first time in... |
code_exercise_27k | 2,251 | Write a Python function named `is_same_object` that takes two arguments, `obj1` and `obj2`. The function should return `True` if `obj1` and `obj2` refer to the same object in memory, and `False` otherwise. The function should use the `is` operator to perform this check.
The code should start with:
```python
def is_sam... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_object(obj1, obj2) -> bool:
"""
Check if obj1 and obj2 refer to the same object in memory.
Parameters:
obj1 (Any): The first object to compare.
obj2 (Any): The second object to compare.
Returns:
... |
code_exercise_27k | 2,252 | Write a Python function named `is_not_same_object` that takes two arguments, `obj1` and `obj2`. The function should return `True` if `obj1` and `obj2` do not refer to the same object in memory, and `False` otherwise. The function should handle any type of objects, including primitive types, lists, dictionaries, and cus... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_object(obj1, obj2) -> bool:
"""
Check if obj1 and obj2 do not refer to the same object in memory.
Parameters:
obj1 (Any): The first object to compare.
obj2 (Any): The second object to compare.
R... |
code_exercise_27k | 2,253 | Write a Python function named `find_all_indices` that takes two arguments, `item` and `lst`. The function should return a list of all indices where `item` is found in the list `lst`. If `item` is not found in `lst`, the function should return an empty list.
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, Any
def find_all_indices(item: Any, lst: List[Any]) -> List[int]:
"""
Find all indices of the given item in the list.
Args:
item (Any): The item to search for in the list.
lst (List... |
code_exercise_27k | 2,256 | Write a Python function named `is_not_same_string` that takes two arguments, `str1` and `str2`. The function should return `True` if `str1` and `str2` are not the same string (considering both content and identity), and `False` otherwise. The function should handle cases where the strings are identical in content but d... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_string(str1: str, str2: str) -> bool:
"""
Check if str1 and str2 are not the same string, considering both identity and content.
Parameters:
str1 (str): The first string.
str2 (str): The second strin... |
code_exercise_27k | 2,257 | Write a Python function named `is_same_list` that takes two arguments, `lst1` and `lst2`. The function should return `True` if `lst1` and `lst2` are the same list (i.e., they refer to the same object in memory), and `False` otherwise. The function should handle cases where `lst1` and `lst2` are `None` and should return... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_list(lst1, lst2):
"""
Check if lst1 and lst2 are the same list (i.e., they refer to the same object in memory).
Parameters:
lst1 (list or None): The first list or None.
lst2 (list or None): The second li... |
code_exercise_27k | 2,258 | Write a Python function named `is_not_same_list` that takes two arguments, `lst1` and `lst2`. The function should return `True` if `lst1` and `lst2` are not the same list (i.e., they are not the same object in memory), and `False` otherwise. The function should handle cases where `lst1` and `lst2` are both `None` as we... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def is_not_same_list(lst1: Optional[List], lst2: Optional[List]) -> bool:
"""
Check if lst1 and lst2 are not the same list.
Parameters:
lst1 (Optional[List]): The first list or None.
... |
code_exercise_27k | 2,259 | Write a Python function named `is_same_dict` that takes two arguments, `dict1` and `dict2`. The function should return `True` if `dict1` and `dict2` are the same dictionary (i.e., they reference the same object in memory), and `False` otherwise. The function should also handle cases where `dict1` and `dict2` are `None`... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_dict(dict1: dict, dict2: dict) -> bool:
"""
Check if dict1 and dict2 are the same dictionary object in memory.
Parameters:
dict1 (dict): The first dictionary.
dict2 (dict): The second dictionary.
Re... |
code_exercise_27k | 2,260 | Write a Python function named `is_not_same_dict` that takes two arguments, `dict1` and `dict2`. The function should return `True` if `dict1` and `dict2` are not the same dictionary (i.e., they are not the same object in memory), and `False` otherwise. The function should also handle cases where `dict1` or `dict2` might... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_dict(dict1: dict, dict2: dict) -> bool:
"""
Check if dict1 and dict2 are not the same dictionary object in memory.
Parameters:
dict1 (dict): The first dictionary.
dict2 (dict): The second dictionary.... |
code_exercise_27k | 2,265 | Write a Python function named `is_same_object_type` that takes two arguments, `obj1` and `obj2`. The function should return `True` if `obj1` and `obj2` have the same type, and `False` otherwise. The function should be able to handle any Python object, including built-in types, custom classes, and instances of those cla... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_object_type(obj1, obj2) -> bool:
"""
Check if obj1 and obj2 have the same type.
Parameters:
obj1 (Any): The first object.
obj2 (Any): The second object.
Returns:
bool: True if obj1 and obj2 have... |
code_exercise_27k | 2,266 | Write a Python function named `is_not_same_object_type` that takes two arguments, `obj1` and `obj2`. The function should return `True` if `obj1` and `obj2` do not have the same type, and `False` otherwise. The function should be able to handle any Python object, including built-in types, custom classes, and instances o... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_object_type(obj1, obj2) -> bool:
"""
Check if obj1 and obj2 do not have the same type.
Parameters:
obj1 (Any): The first object.
obj2 (Any): The second object.
Returns:
bool: True if obj1 an... |
code_exercise_27k | 2,267 | Write a Python function named `is_same_boolean` that takes two arguments, `bool1` and `bool2`. The function should return `True` if `bool1` and `bool2` have the same boolean value, and `False` otherwise. The function should handle any type of input, converting them to their boolean equivalents using Python's built-in `... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_boolean(bool1, bool2) -> bool:
"""
Check if bool1 and bool2 have the same boolean value.
This function converts both inputs to their boolean equivalents using the `bool()` function
and then compares these bo... |
code_exercise_27k | 2,268 | Write a Python function named `is_not_same_boolean` that takes two arguments, `bool1` and `bool2`. The function should return `True` if `bool1` and `bool2` do not have the same boolean value, and `False` otherwise. The function should handle any input that can be converted to a boolean (e.g., `None`, `0`, `1`, `True`, ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_boolean(bool1, bool2) -> bool:
"""
Check if bool1 and bool2 do not have the same boolean value.
Parameters:
bool1 (Any): The first value to be converted to a boolean.
bool2 (Any): The second value to... |
code_exercise_27k | 2,269 | Write a Python function named `is_same_number` that takes two arguments, `num1` and `num2`. The function should return `True` if `num1` and `num2` have the same numerical value, and `False` otherwise. The function should handle both integers and floating-point numbers.
The code should start with:
```python
def is_same... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_number(num1: int | float, num2: int | float) -> bool:
"""
Check if num1 and num2 have the same numerical value.
Parameters:
num1 (int or float): The first number.
num2 (int or float): The second number.
... |
code_exercise_27k | 2,270 | Write a Python function named `is_not_same_number` that takes two arguments, `num1` and `num2`. The function should return `True` if `num1` and `num2` do not have the same numerical value, and `False` otherwise. The function should handle both integer and floating-point numbers.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_number(num1: int | float, num2: int | float) -> bool:
"""
Check if num1 and num2 do not have the same numerical value.
Parameters:
num1 (int or float): The first number.
num2 (int or float): The seco... |
code_exercise_27k | 2,272 | Write a Python function named `is_not_same_integer` that takes two arguments, `int1` and `int2`. The function should return `True` if `int1` and `int2` do not have the same integer value, and `False` otherwise. The function should handle any input that can be converted to an integer, including strings and floats.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_integer(int1, int2) -> bool:
"""
Check if int1 and int2 do not have the same integer value.
Parameters:
int1 (int or str or float): The first input that can be converted to an integer.
int2 (int or s... |
code_exercise_27k | 2,276 | Write a Python function named `is_not_same_complex` that takes two arguments, `complex1` and `complex2`. The function should return `True` if `complex1` and `complex2` do not have the same complex value, and `False` otherwise. The function should handle both complex numbers and strings that can be converted to complex ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_complex(complex1, complex2) -> bool:
"""
Check if complex1 and complex2 do not have the same complex value.
Parameters:
complex1 (complex or str): The first complex number or its string representation.
... |
code_exercise_27k | 2,277 | Write a Python function named `are_both_none` that takes two arguments, `obj1` and `obj2`. The function should return `True` if both `obj1` and `obj2` are `None`, and `False` otherwise. The function should be robust and handle any type of input.
The code should start with:
```python
def are_both_none(obj1, obj2) -> bo... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_both_none(obj1, obj2) -> bool:
"""
Check if both obj1 and obj2 are None.
Parameters:
obj1 (Any): The first object to check.
obj2 (Any): The second object to check.
Returns:
bool: True if both obj1 a... |
code_exercise_27k | 2,278 | Write a Python function named `is_not_same_none` that takes two arguments, `obj1` and `obj2`. The function should return `True` if either `obj1` or `obj2` is not `None`, and `False` if both are `None`. The function should handle any type of input, including `None`.
The code should start with:
```python
def is_not_same... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_none(obj1, obj2) -> bool:
"""
Check if either obj1 or obj2 is not None.
Parameters:
obj1 (Any): The first object.
obj2 (Any): The second object.
Returns:
bool: True if either obj1 or obj2 is... |
code_exercise_27k | 2,279 | Write a Python function named `are_strings_empty` that takes two arguments, `str1` and `str2`. The function should return `True` if both `str1` and `str2` are empty strings, and `False` otherwise. The function should also handle cases where `str1` or `str2` might be `None`. If either `str1` or `str2` is `None`, the fun... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_strings_empty(str1: str, str2: str) -> bool:
"""
Check if both str1 and str2 are empty strings.
Args:
str1 (str): The first string.
str2 (str): The second string.
Returns:
bool: True if ... |
code_exercise_27k | 2,280 | Write a Python function named `is_not_same_empty_string` that takes two arguments, `str1` and `str2`. The function should return `True` if either `str1` or `str2` is not an empty string, and `False` if both are empty strings. The function should handle cases where the inputs are not strings by converting them to string... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_empty_string(str1, str2) -> bool:
"""
Check if either str1 or str2 is not an empty string after converting both to strings.
Parameters:
str1 (Any): The first input to be converted to a string.
str2 (... |
code_exercise_27k | 2,281 | Write a Python function named `are_lists_empty` that takes two arguments, `lst1` and `lst2`. The function should return `True` if both `lst1` and `lst2` are empty lists, and `False` otherwise. The function should also handle cases where the inputs are not lists by returning `False`.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def are_lists_empty(lst1: List[Any], lst2: List[Any]) -> bool:
"""
Check if both lst1 and lst2 are empty lists.
Args:
lst1 (List[Any]): The first list to check.
lst2 (List[Any])... |
code_exercise_27k | 2,282 | Write a Python function named `is_not_same_empty_list` that takes two arguments, `lst1` and `lst2`. The function should return `True` if either `lst1` or `lst2` is not an empty list, and `False` if both are empty lists. The function should handle lists of any type, including nested lists and lists containing different ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def is_not_same_empty_list(lst1: List[Any], lst2: List[Any]) -> bool:
"""
Check if either lst1 or lst2 is not an empty list.
Args:
lst1 (List[Any]): The first list.
lst2 (List[A... |
code_exercise_27k | 2,283 | Write a Python function named `are_dicts_empty` that takes two arguments, `dict1` and `dict2`. The function should return `True` if both `dict1` and `dict2` are empty dictionaries, and `False` otherwise. The function should also handle cases where the inputs are not dictionaries by returning `False`.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_dicts_empty(dict1, dict2) -> bool:
"""
Check if both dict1 and dict2 are empty dictionaries.
Parameters:
dict1 (dict): The first dictionary.
dict2 (dict): The second dictionary.
Returns:
bool: True ... |
code_exercise_27k | 2,284 | Write a Python function named `is_not_same_empty_dict` that takes two arguments, `dict1` and `dict2`. The function should return `True` if either `dict1` or `dict2` is not an empty dictionary, and `False` if both are empty dictionaries. The function should handle cases where the inputs are not dictionaries by returning... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_empty_dict(dict1, dict2):
"""
Check if either dict1 or dict2 is not an empty dictionary.
Parameters:
dict1 (dict): The first dictionary.
dict2 (dict): The second dictionary.
Returns:
bool: T... |
code_exercise_27k | 2,285 | Write a Python function named `are_sets_empty` that takes two arguments, `set1` and `set2`. The function should return `True` if both `set1` and `set2` are empty sets, and `False` otherwise. The function should handle cases where the inputs are not sets by raising a `TypeError`.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_sets_empty(set1, set2):
"""
Check if both set1 and set2 are empty sets.
Parameters:
set1 (set): The first set to check.
set2 (set): The second set to check.
Returns:
bool: True if both set1 and set2... |
code_exercise_27k | 2,286 | Write a Python function named `is_not_same_empty_set` that takes two arguments, `set1` and `set2`. The function should return `True` if either `set1` or `set2` is not an empty set, and `False` if both are empty sets. The function should handle sets of any size, including empty sets.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_empty_set(set1: set, set2: set) -> bool:
"""
Check if either set1 or set2 is not an empty set.
Args:
set1 (set): The first set to check.
set2 (set): The second set to check.
Returns:
... |
code_exercise_27k | 2,287 | Write a Python function named `is_same_length` that takes two arguments, `obj1` and `obj2`. The function should return `True` if the length of `obj1` is equal to the length of `obj2`, and `False` otherwise. Note that `obj1` and `obj2` can be any iterable objects. The function should handle cases where the objects are n... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_length(obj1, obj2) -> bool:
"""
Check if the length of obj1 is equal to the length of obj2.
Parameters:
obj1 (iterable): The first iterable object.
obj2 (iterable): The second iterable object.
Retur... |
code_exercise_27k | 2,288 | Write a Python function named `is_not_same_length` that takes two arguments, `obj1` and `obj2`. The function should return `True` if the length of `obj1` is not equal to the length of `obj2`, and `False` otherwise. Note that `obj1` and `obj2` can be any iterable objects. The function should handle cases where the objec... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_not_same_length(obj1, obj2):
"""
Check if the length of obj1 is not equal to the length of obj2.
Parameters:
obj1 (iterable): The first iterable object.
obj2 (iterable): The second iterable object.
Retur... |
code_exercise_27k | 2,289 | Write a Python function named `is_same_truthiness` that takes two arguments, `obj1` and `obj2`. The function should return `True` if both `obj1` and `obj2` evaluate to the same truthiness, and `False` otherwise. The function should handle any Python object, including but not limited to integers, strings, lists, and cus... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_same_truthiness(obj1, obj2) -> bool:
"""
Check if obj1 and obj2 evaluate to the same truthiness.
Parameters:
obj1 (Any): The first object to evaluate.
obj2 (Any): The second object to evaluate.
Returns:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.