source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 1,456 | Write a Python function named `count_substring` that takes two strings as input: a main string and a substring. The function should return the number of non-overlapping occurrences of the substring in the main string. The function should handle edge cases such as empty strings and substrings that are longer than the ma... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_substring(main_string: str, substring: str) -> int:
"""
Counts the number of non-overlapping occurrences of a substring in a main string.
Args:
main_string (str): The main string in which to search for the... |
code_exercise_27k | 1,459 | Write a Python function named `split_string` that takes two strings as input: a main string and a delimiter. The function should return a list of substrings obtained by splitting the main string at each occurrence of the delimiter. If the delimiter is an empty string, the function should return a list of characters fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def split_string(main_string: str, delimiter: str) -> List[str]:
"""
Splits the main string at each occurrence of the delimiter and returns a list of substrings.
Args:
main_string (str): The... |
code_exercise_27k | 1,460 | Write a Python function named `join_strings` that takes a list of strings and a delimiter as input. The function should return a new string where all the strings in the list are joined together with the delimiter in between each pair of strings. The function should handle cases where the list is empty or contains only ... | 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 with a specified delimiter.
Args:
string_list (List[str]): A list of strings to be joined.
... |
code_exercise_27k | 1,461 | Write a Python function named `extract_digits` that takes a string as input and returns a new string containing only the digits (0-9) present in the input string. The order of the digits should be preserved. The function should handle various edge cases, such as an empty string or a string with no digits.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_digits(input_string: str) -> str:
"""
Extracts and returns a string containing only the digits (0-9) from the input string.
The order of the digits is preserved.
Args:
input_string (str): The input s... |
code_exercise_27k | 1,463 | Write a Python function named `reverse_words_case_sensitive` that takes a string as input and returns a new string where the order of the words is reversed, while preserving the case sensitivity of each word. Assume that words are separated by spaces and there are no punctuation marks. The function should handle empty ... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_case_sensitive(input_string: str) -> str:
"""
Reverses the order of words in the input string while preserving the case sensitivity of each word.
Args:
input_string (str): The input string containi... |
code_exercise_27k | 1,465 | Write a Python function named `replace_words` that takes three strings as input: a main string, a word to be replaced, and a replacement word. The function should return a new string where all occurrences of the word in the main string are replaced with the replacement word. Assume that words are separated by spaces an... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_words(main_string: str, word: str, replacement: str) -> str:
"""
Replaces all occurrences of a specified word in a main string with a replacement word.
Args:
main_string (str): The main string in which t... |
code_exercise_27k | 1,466 | Write a Python function named `count_characters` that takes a string as input and returns a dictionary containing the count of each character in the string. The keys of the dictionary should be the unique characters in the string, and the values should be the corresponding counts. The function should handle an empty st... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_characters(input_string: str) -> dict:
"""
Counts the occurrences of each character in the input string.
Args:
input_string (str): The string to count characters from.
Returns:
dict: A diction... |
code_exercise_27k | 1,468 | Write a Python function named `reverse_words_case_insensitive` that takes a string as input and returns a new string where the order of the words is reversed, while ignoring case sensitivity. The function should ensure that the case of each character in the original string is preserved in the output. Assume that words ... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_case_insensitive(input_string: str) -> str:
"""
Reverses the order of words in a given string while ignoring case sensitivity.
The case of each character in the original string is preserved in the output.
... |
code_exercise_27k | 1,470 | Write a Python function named `count_substring_case_insensitive` that takes two strings as input: a main string and a substring. The function should return the number of times the substring appears in the main string, while ignoring case sensitivity. The function should handle edge cases such as empty strings and subst... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_substring_case_insensitive(main_string: str, substring: str) -> int:
"""
Counts the number of times a substring appears in a main string, ignoring case sensitivity.
Args:
main_string (str): The main string... |
code_exercise_27k | 1,472 | Write a Python function named `remove_whitespace_case_insensitive` that takes a string as input and returns a new string where all whitespace characters (spaces, tabs, and newlines) are removed, while ignoring case sensitivity. The function should also ensure that the original string's case is preserved in the output.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace_case_insensitive(input_string: str) -> str:
"""
Removes all whitespace characters (spaces, tabs, and newlines) from the input string while preserving the original case.
Args:
input_string (str)... |
code_exercise_27k | 1,473 | Write a Python function named `split_string_case_insensitive` that takes two strings as input: a main string and a delimiter. The function should return a list of substrings obtained by splitting the main string at each occurrence of the delimiter, while ignoring case sensitivity. The function should handle edge cases ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def split_string_case_insensitive(main_string: str, delimiter: str) -> List[str]:
"""
Splits the main string at each occurrence of the delimiter, ignoring case sensitivity.
Args:
main_string... |
code_exercise_27k | 1,475 | Write a Python function named `count_characters_case_insensitive` that takes a string as input and returns a dictionary containing the count of each character in the string, while ignoring case sensitivity. The keys of the dictionary should be the unique characters in the string, and the values should be the correspond... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_characters_case_insensitive(input_string: str) -> Dict[str, int]:
"""
Counts the occurrences of each character in the input string, ignoring case sensitivity.
Args:
input_string (s... |
code_exercise_27k | 1,478 | Write a Python function named `count_vowels_case_insensitive` that takes a string as input and returns the number of vowels (a, e, i, o, u) in the string, while ignoring case sensitivity. The function should handle both uppercase and lowercase vowels.
The code should start with:
```python
def count_vowels_case_insensi... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels_case_insensitive(input_string: str) -> int:
"""
Counts the number of vowels (a, e, i, o, u) in the input string, ignoring case sensitivity.
Args:
input_string (str): The string in which to count the... |
code_exercise_27k | 1,480 | Write a Python function named `count_words_case_insensitive` that takes a string as input and returns the number of words in the string, while ignoring case sensitivity. Assume that words are separated by spaces and there are no punctuation marks. The function should handle empty strings and strings with varying case s... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_words_case_insensitive(input_string: str) -> int:
"""
Counts the number of words in a given string, ignoring case sensitivity.
Args:
input_string (str): The input string to count words from.
Returns:
... |
code_exercise_27k | 1,482 | Write a Python function named `remove_digits` that takes a string as input and returns a new string where all digits (0-9) are removed. The function should handle various edge cases, such as an empty string or a string with no digits. The code should start with:
```python
import re
def remove_digits(input_string: str)... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_digits(input_string: str) -> str:
"""
Removes all digits from the given input string.
Args:
input_string (str): The input string from which digits are to be removed.
Returns:
str: ... |
code_exercise_27k | 1,483 | Write a Python function named `count_special_characters` that takes a string as input and returns the count of special characters (non-alphanumeric characters) in the string. The function should use regular expressions to identify and count these characters.
The code should start with:
```python
import re
def count_s... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def count_special_characters(input_string: str) -> int:
"""
Counts the number of special characters (non-alphanumeric characters) in the given string.
Args:
input_string (str): The string in which to coun... |
code_exercise_27k | 1,484 | Write a Python function named `remove_non_alpha_characters` that takes a string as input and returns a new string where all non-alphabetic characters are removed. The function should handle various edge cases, such as empty strings, strings with only non-alphabetic characters, and strings with mixed characters. The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_non_alpha_characters(input_string: str) -> str:
"""
Removes all non-alphabetic characters from the given input string.
Args:
input_string (str): The input string from which non-alphabetic chara... |
code_exercise_27k | 1,485 | Write a Python function named `count_uppercase_characters` that takes a string as input and returns the count of uppercase characters in the string. The function should handle an empty string and strings with no uppercase characters. The code should start with:
```python
def count_uppercase_characters(input_string: str... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_uppercase_characters(input_string: str) -> int:
"""
Counts the number of uppercase characters in the given string.
Args:
input_string (str): The string to count uppercase characters from.
Returns:
... |
code_exercise_27k | 1,486 | Write a Python function named `remove_lowercase_characters` that takes a string as input and returns a new string where all lowercase characters are removed. The function should handle an empty string and strings with no lowercase characters gracefully. The code should start with:
```python
def remove_lowercase_charact... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_lowercase_characters(input_string: str) -> str:
"""
Removes all lowercase characters from the given input string.
Args:
input_string (str): The input string from which to remove lowercase characters.
... |
code_exercise_27k | 1,487 | Write a Python function named `count_lowercase_characters` that takes a string as input and returns the count of lowercase characters in the string. The function should handle an empty string and strings with no lowercase characters. The code should start with:
```python
def count_lowercase_characters(input_string: str... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_lowercase_characters(input_string: str) -> int:
"""
Counts the number of lowercase characters in the given string.
Args:
input_string (str): The string to count lowercase characters from.
Returns:
... |
code_exercise_27k | 1,489 | Write a Python function named `count_alpha_characters` that takes a string as input and returns the count of alphabetic characters in the string. The function should ignore any non-alphabetic characters, including spaces, numbers, and special characters. The code should start with:
```python
def count_alpha_characters(... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_alpha_characters(input_string: str) -> int:
"""
Counts the number of alphabetic characters in the given string.
Args:
input_string (str): The string to count alphabetic characters from.
Returns:
... |
code_exercise_27k | 1,493 | Write a Python function named `remove_substring` that takes two strings as input: a main string and a substring. The function should return a new string where all occurrences of the substring in the main string are removed. The function should handle cases where the substring is not found in the main string and should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_substring(main_string: str, substring: str) -> str:
"""
Removes all occurrences of a substring from a main string.
Args:
main_string (str): The main string from which to remove the substring.
subs... |
code_exercise_27k | 1,494 | Write a Python function named `remove_substring_case_insensitive` that takes two strings as input: a main string and a substring. The function should return a new string where all occurrences of the substring in the main string are removed, while ignoring case sensitivity. The function should handle edge cases such as ... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_substring_case_insensitive(main_string: str, substring: str) -> str:
"""
Removes all occurrences of a substring from a main string, ignoring case sensitivity.
Args:
main_string (str): The main string from... |
code_exercise_27k | 1,495 | Write a Python function named `remove_whitespace_case_sensitive` that takes a string as input and returns a new string where all whitespace characters (spaces, tabs, and newlines) are removed, while preserving case sensitivity. The function should handle various types of whitespace characters and return the modified st... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace_case_sensitive(input_string: str) -> str:
"""
Removes all whitespace characters (spaces, tabs, and newlines) from the input string while preserving case sensitivity.
Args:
input_string (str): T... |
code_exercise_27k | 1,496 | Write a Python function named `reverse_words_case_sensitive` that takes a string as input and returns a new string where the order of the words is reversed, while preserving the case sensitivity of each word. Assume that words are separated by spaces and there are no punctuation marks. The function should handle edge c... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_case_sensitive(input_string: str) -> str:
"""
Reverses the order of words in the input string while preserving the case sensitivity of each word.
Args:
input_string (str): The input string containi... |
code_exercise_27k | 1,497 | Write a Python function named `count_words_case_sensitive` that takes a string as input and returns the number of words in the string, while preserving case sensitivity. Assume that words are separated by spaces and there are no punctuation marks. The function should handle edge cases such as empty strings and strings ... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_words_case_sensitive(input_string: str) -> int:
"""
Counts the number of words in a given string while preserving case sensitivity.
Words are assumed to be separated by spaces and there are no punctuation marks.
... |
code_exercise_27k | 1,500 | Write a Python function named `count_special_characters_case_insensitive` that takes a string as input and returns the count of special characters (non-alphanumeric characters) in the string, while ignoring case sensitivity. The function should handle both uppercase and lowercase characters uniformly.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def count_special_characters_case_insensitive(input_string: str) -> int:
"""
Counts the number of special characters (non-alphanumeric characters) in the input string, ignoring case sensitivity.
Args:
inp... |
code_exercise_27k | 1,501 | Write a Python function named `add_numbers` that takes two integer parameters, `num1` and `num2`, and returns the sum of the two numbers. The function should be able to handle both positive and negative integers. The code should start with:
```python
def add_numbers(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def add_numbers(num1: int, num2: int) -> int:
"""
This function takes two integer parameters, num1 and num2, and returns the sum of the two numbers.
Parameters:
num1 (int): The first integer number.
num2 (int): ... |
code_exercise_27k | 1,502 | Write a Python function named `multiply_numbers` that takes two integer parameters, `num1` and `num2`, and returns the product of the two numbers. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def multiply_numbers(num1: int, num2: int) -> int:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_numbers(num1: int, num2: int) -> int:
"""
Computes the product of two integer numbers.
This function takes two integer parameters, num1 and num2, and returns their product.
It handles both positive and nega... |
code_exercise_27k | 1,503 | Write a Python function named `is_even` that takes an integer parameter `num` 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 number to check.
Returns:
bool: True if the number is even, False otherwise.
"""
# Use the ... |
code_exercise_27k | 1,504 | Write a Python function named `is_prime` that takes an integer parameter `num` and returns `True` if the number is prime, and `False` otherwise. The function should efficiently determine the primality of the number by checking divisibility up to the square root of the number.
The code should start with:
```python
def ... | 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 integer is a prime number.
Args:
num (int): The integer number to check for primality.
Returns:
bool: True if the number is prime, False otherwi... |
code_exercise_27k | 1,505 | Write a Python function named `find_factorial` that takes an integer parameter `num` and returns the factorial of the 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 defined to be 1. The function should handle both positive and... | 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 non-negative integer.
The factorial of a non-negative integer n is the product of all positive integers
less than or equal to n. The factorial ... |
code_exercise_27k | 1,506 | Write a Python function named `reverse_number` that takes an integer parameter `num` and returns the reverse of the number. The function should handle both positive and negative integers. The reversed number should maintain the sign of the original number.
The code should start with:
```python
def reverse_number(num: ... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_number(num: int) -> int:
"""
Reverses the digits of an integer while maintaining its sign.
Args:
num (int): The integer number to reverse.
Returns:
int: The reversed number with the original... |
code_exercise_27k | 1,507 | Write a Python function named `count_digits` that takes an integer parameter `num` and returns the count of digits in the number. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def count_digits(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_digits(num: int) -> int:
"""
Counts the number of digits in a given integer.
Args:
num (int): The integer number to count the digits for.
Returns:
int: The count of digits in the number.
"... |
code_exercise_27k | 1,508 | Write a Python function named `is_palindrome` that takes an integer parameter `num` and returns `True` if the number is a palindrome, and `False` otherwise. A palindrome number reads the same backward as forward. The function should handle both positive and negative integers.
The code should start with:
```python
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(num: int) -> bool:
"""
Determines if a given integer is a palindrome.
A palindrome number reads the same backward as forward. This function handles both positive and negative integers.
Args:
n... |
code_exercise_27k | 1,509 | Write a Python function named `find_gcd` that takes two integer 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, num... | 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 integers using the Euclidean algorithm.
Args:
num1 (int): The first integer number.
num2 (int): The second in... |
code_exercise_27k | 1,511 | Write a Python function named `is_armstrong` that takes an integer parameter `num` and returns `True` if the number is an Armstrong number, and `False` otherwise. An Armstrong number (also known as a narcissistic number) is a number that is the sum of its own digits each raised to the power of the number of digits.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_armstrong(num: int) -> bool:
"""
Determines if a given number is an Armstrong number.
An Armstrong number (or narcissistic number) is a number that is the sum of its own digits
each raised to the power of the num... |
code_exercise_27k | 1,513 | Write a Python function named `sum_of_digits` that takes an integer parameter `num` and returns the sum of its digits. The function should handle both positive and negative integers. The code should start with:
```python
def sum_of_digits(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_digits(num: int) -> int:
"""
Calculate the sum of the digits of a given integer.
Args:
num (int): The integer number to find the sum of its digits.
Returns:
int: The sum of the digits of the ... |
code_exercise_27k | 1,514 | Write a Python function named `find_average` that takes a list of integers as a parameter and returns the average of the numbers in the list. The function should handle cases where the list is empty by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_average(numbers: L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_average(numbers: List[int]) -> Optional[float]:
"""
Calculate the average of a list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
Optio... |
code_exercise_27k | 1,515 | Write a Python function named `find_max` that takes a list of integers as a parameter and returns the maximum value in the list. The function should not use Python's built-in `max` function or any other built-in functions that directly solve the problem. Instead, implement the logic manually to find the maximum value.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max(numbers: List[int]) -> int:
"""
Finds the maximum value in a list of integers without using built-in max function.
Args:
numbers (List[int]): A list of integers.
Returns:
... |
code_exercise_27k | 1,516 | Write a Python function to find the minimum value in a list of integers without using the built-in `min()` function. The function should iterate through the list and keep track of the smallest value encountered. The code should start with:
```python
from typing import List
def find_min_value(numbers: List[int]) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_min_value(numbers: List[int]) -> int:
"""
Find the minimum value in a list of integers without using the built-in min() function.
Args:
numbers (List[int]): A list of integers.
... |
code_exercise_27k | 1,517 | Write a Python function named `is_perfect_square` that takes an integer parameter `num` and returns `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(num: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_perfect_square(num: int) -> bool:
"""
Determines if a given integer is a perfect square.
Args:
num (int): The integer number to check for perfect square.
Returns:
bool: True if the number is a pe... |
code_exercise_27k | 1,518 | Write a Python function named `find_power` that takes two integer parameters, `base` and `exponent`, and returns the result of raising the base to the exponent. The function should handle both positive and negative exponents. The code should start with:
```python
def find_power(base: int, exponent: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_power(base: int, exponent: int) -> int:
"""
Calculate the result of raising the base to the exponent.
Args:
base (int): The base number.
exponent (int): The exponent number.
Returns:
in... |
code_exercise_27k | 1,521 | Write a Python function named `generate_fibonacci` that takes an integer 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 o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_fibonacci(n: int) -> List[int]:
"""
Generate the first n Fibonacci numbers.
Args:
n (int): The number of Fibonacci numbers to generate.
Returns:
List[int]: A list c... |
code_exercise_27k | 1,522 | Write a Python function named `find_sum_of_even_digits` that takes an integer parameter `num` and returns the sum of the even digits in the number. The function should handle both positive and negative integers.
The code should start with:
```python
def find_sum_of_even_digits(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_even_digits(num: int) -> int:
"""
Calculate the sum of the even digits in a given integer.
Args:
num (int): The integer number to find the sum of its even digits.
Returns:
int: The sum o... |
code_exercise_27k | 1,523 | Write a Python function named `find_sum_of_odd_digits` that takes an integer parameter `num` and returns the sum of the odd digits in the number. The function should handle both positive and negative integers.
The code should start with:
```python
def find_sum_of_odd_digits(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_odd_digits(num: int) -> int:
"""
Calculate the sum of the odd digits in a given integer.
Args:
num (int): The integer number to find the sum of its odd digits.
Returns:
int: The sum of t... |
code_exercise_27k | 1,524 | Write a Python function named `reverse_list` that takes a list parameter `lst` and returns a new list with the elements in reverse order. The function should not modify the original list and should use a list comprehension to achieve the reversal.
The code should start with:
```python
from typing import List
def reve... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list(lst: List[int]) -> List[int]:
"""
Returns a new list with the elements of the input list in reverse order.
Args:
lst (List[int]): The input list of integers.
Returns:
... |
code_exercise_27k | 1,525 | Write a Python function named `find_common_elements` that takes two lists as parameters, `lst1` and `lst2`, and returns a new list containing the common elements between the two lists. The function should handle cases where the lists contain duplicate elements and should return the common elements in the order they app... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements(lst1: List[int], lst2: List[int]) -> List[int]:
"""
Finds and returns a list of common elements between two lists, preserving the order of their first appearance in the first lis... |
code_exercise_27k | 1,527 | Write a Python function named `find_missing_numbers` that takes two lists as parameters, `lst1` and `lst2`, and returns a new list containing the numbers that are present in `lst1` but not in `lst2`. The function should be efficient and handle edge cases such as empty lists and lists with duplicate elements.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_numbers(lst1: List[int], lst2: List[int]) -> List[int]:
"""
Returns a new list containing the numbers that are present in lst1 but not in lst2.
Args:
lst1 (List[int]): The f... |
code_exercise_27k | 1,530 | Write a Python function named `find_max_occurrence` that takes a list parameter `lst` and returns the element with the maximum occurrence in the list. If multiple elements have the same maximum occurrence, return the one that appears first. The function should be efficient and handle various edge cases, such as an empt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def find_max_occurrence(lst: List[Any]) -> Any:
"""
Finds the element with the maximum occurrence in the given list.
If multiple elements have the same maximum occurrence, returns the one that a... |
code_exercise_27k | 1,532 | Write a Python function named `find_median` that takes a list parameter `lst` and returns the median value of the elements in the list. Assume the list is non-empty and contains only numeric values. The function should handle both even and odd lengths of the list. The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_median(lst: List[float]) -> float:
"""
Calculate the median value of a list of numeric values.
Args:
lst (List[float]): A list of numeric values.
Returns:
float: The me... |
code_exercise_27k | 1,533 | Write a Python function named `find_mode` that takes a list parameter `lst` and returns a list of the mode(s) of the elements in the list. The mode is the value(s) that appear(s) most frequently in the list. If there are multiple elements with the same highest frequency, the function should return all of them.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_mode(lst: List[int]) -> List[int]:
"""
Finds the mode(s) of the elements in the given list. The mode is the value(s) that appear(s) most frequently in the list.
Args:
lst (List[int]... |
code_exercise_27k | 1,534 | Write a Python function named `find_range` that takes a list parameter `lst` and returns the range of the elements in the list. The range is defined as the difference between the maximum and minimum values in the list. The function should handle lists of integers and floating-point numbers. 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_range(lst: List[Union[int, float]]) -> Union[int, float]:
"""
Calculate the range of elements in a list, which is the difference between the maximum and minimum values.
Args:
... |
code_exercise_27k | 1,536 | Write a Python function named `find_product` that takes a list parameter `lst` and returns the product of the elements in the list. The function should handle lists containing integers and floats. The code should start with:
```python
from typing import List
def find_product(lst: List[float]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_product(lst: List[float]) -> float:
"""
Calculate the product of all elements in the given list.
Args:
lst (List[float]): A list of numeric values (integers or floats).
Returns... |
code_exercise_27k | 1,538 | Write a Python function named `count_negative_numbers` that takes a list of integers as input and returns the count of negative numbers in the 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 start with:
```python
from typin... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_negative_numbers(lst: List[int]) -> int:
"""
Counts the number of negative numbers in a given list of integers.
Args:
lst (List[int]): A list of integers.
Returns:
int... |
code_exercise_27k | 1,541 | Write a Python function named `count_positive_numbers` that takes a list of integers as input and returns the count of positive 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 count_positive_numbers(lst: List[int]) -> int:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_positive_numbers(lst: List[int]) -> int:
"""
Counts the number of positive integers in the given list.
Args:
lst (List[int]): A list of integers.
Returns:
int: The cou... |
code_exercise_27k | 1,547 | Write a Python function named `is_palindrome_long_number` that takes a long number as input and returns `True` if the number is a palindrome, and `False` otherwise. The function should handle very large numbers efficiently and should not rely on converting the entire number to a string. Instead, it should use a more ef... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_long_number(num: int) -> bool:
"""
Determines if a given long number is a palindrome.
Args:
num (int): The number to check for being a palindrome.
Returns:
bool: True if the number is ... |
code_exercise_27k | 1,548 | Write a Python function named `sum_of_digits_long_number` that takes a long number as input and returns the sum of its digits. The input can be either an integer or a string representation of a number. The function should handle both cases and return the correct sum of digits.
The code should start with:
```python
def... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
def sum_of_digits_long_number(num: Union[int, str]) -> int:
"""
Calculate the sum of the digits of a long number.
Args:
num (Union[int, str]): The number whose digits are to be summed. Can ... |
code_exercise_27k | 1,549 | Write a Python function named `is_prime_long_number` that takes a long number as input and returns `True` if the number is prime, and `False` otherwise. The input number is provided as a string to handle very large numbers. The function should handle large numbers efficiently and correctly determine their primality.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def is_prime_long_number(num: str) -> bool:
"""
Determines if a very large number (provided as a string) is prime.
Args:
num (str): The number to check for primality, provided as a string.
Returns:... |
code_exercise_27k | 1,550 | Write a Python function named `factorial_long_number` that takes a long number as input and returns its factorial. The input number can be provided as a string, integer, or float. The function should handle large numbers efficiently and return the factorial as an integer.
The code should start with:
```python
def fact... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
def factorial_long_number(num: Union[str, int, float]) -> int:
"""
Calculate the factorial of a given long number.
Args:
num (Union[str, int, float]): The number for which to calculate the ... |
code_exercise_27k | 1,551 | Write a Python function named `is_armstrong_number` that takes an integer as input and returns `True` if the number is an Armstrong number, and `False` otherwise. An Armstrong number (also known as a narcissistic number) is a number that is the sum of its own digits each raised to the power of the number of digits.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_armstrong_number(num: int) -> bool:
"""
Determines if a given number is an Armstrong number.
An Armstrong number (or narcissistic number) is a number that is the sum of its own digits
each raised to the power of ... |
code_exercise_27k | 1,558 | Write a Python function named `is_palindrome_binary_long_number` that takes a binary number as input and returns `True` if the number is a palindrome, and `False` otherwise. The binary number will be provided as a string. The function should handle large binary numbers efficiently.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_binary_long_number(binary: str) -> bool:
"""
Determines if a given binary number (represented as a string) is a palindrome.
Args:
binary (str): The binary number to check, provided as a string.
... |
code_exercise_27k | 1,559 | Write a Python function named `count_ones_in_binary` that takes a binary number as a string input and returns the count of ones in the binary number. The function should handle binary strings of arbitrary length. The code should start with:
```python
def count_ones_in_binary(binary_str: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_ones_in_binary(binary_str: str) -> int:
"""
Counts the number of ones in a given binary string.
Args:
binary_str (str): The binary number represented as a string.
Returns:
int: The count of on... |
code_exercise_27k | 1,565 | Write a Python function named `count_zeros_binary_long_number` that takes a binary number as input and returns the count of zeros in the number. The binary number is represented as a string. The function should handle large binary numbers efficiently.
The code should start with:
```python
def count_zeros_binary_long_n... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_zeros_binary_long_number(binary: str) -> int:
"""
Counts the number of zeros in a binary number represented as a string.
Args:
binary (str): The binary number as a string.
Returns:
int: The co... |
code_exercise_27k | 1,569 | Write a Python function named `is_power_of_two_binary` that takes a binary string as input and returns `True` if the number represented by the binary string is a power of two, and `False` otherwise. The function should handle binary strings of arbitrary length.
The code should start with:
```python
def is_power_of_two... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_power_of_two_binary(binary: str) -> bool:
"""
Determines if the given binary string represents a number that is a power of two.
Args:
binary (str): A string representing a binary number.
Returns:
... |
code_exercise_27k | 1,572 | Write a Python function named `is_odd_binary_long_number` that takes a binary number as input and returns `True` if the number is odd, and `False` otherwise. The function should handle binary strings of arbitrary length. The code should start with:
```python
def is_odd_binary_long_number(binary: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_odd_binary_long_number(binary: str) -> bool:
"""
Determines if a given binary number is odd.
Args:
binary (str): The binary number represented as a string.
Returns:
bool: True if the binary numbe... |
code_exercise_27k | 1,577 | Write a Python function named `is_divisible_by_sixteen` that takes a binary string as input and returns `True` if the binary number represented by the string is divisible by sixteen, and `False` otherwise. The function should be efficient and handle binary strings of arbitrary length.
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible_by_sixteen(binary_str: str) -> bool:
"""
Determines if the binary number represented by the input string is divisible by sixteen.
Args:
binary_str (str): A string representing a binary number.
... |
code_exercise_27k | 1,580 | Write a Python function named `is_palindrome_integer` that takes an integer as input and returns `True` if the integer is a palindrome, and `False` otherwise. A palindrome integer reads the same backward as forward. The function should handle both positive and negative integers.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_integer(num: int) -> bool:
"""
Determines if the given integer is a palindrome.
Args:
num (int): The integer to check for palindrome property.
Returns:
bool: True if the integer is a p... |
code_exercise_27k | 1,581 | Write a Python function named `is_palindrome_list` that takes a list as input and returns `True` if the list is a palindrome, and `False` otherwise. A list is considered a palindrome if it reads the same backward as forward. The function should handle lists of any length, including empty lists.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_palindrome_list(lst: List[int]) -> bool:
"""
Determines if a given list is a palindrome.
A list is considered a palindrome if it reads the same backward as forward.
Args:
lst (Li... |
code_exercise_27k | 1,588 | Write a Python function named `is_palindrome_long_list` that takes a long list as input and returns `True` if the list is a palindrome, and `False` otherwise. The function should be optimized for performance, especially for large lists, and should not use the slicing operation `lst[::-1]` due to its inefficiency with l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_palindrome_long_list(lst: List[int]) -> bool:
"""
Determines if a given long list is a palindrome.
Args:
lst (List[int]): The list to check for palindrome property.
Returns:
... |
code_exercise_27k | 1,589 | Write a Python function named `is_palindrome_long_tuple` that takes a long tuple as input and returns `True` if the tuple is a palindrome, and `False` otherwise. A tuple is considered a palindrome if it reads the same forwards and backwards. The function should handle tuples of any length, including empty tuples.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_long_tuple(tpl: tuple) -> bool:
"""
Determines if a given tuple is a palindrome.
A tuple is considered a palindrome if it reads the same forwards and backwards.
Args:
tpl (tuple): The tuple to... |
code_exercise_27k | 1,594 | Write a Python function named `divide_floats` that takes two float numbers as input and returns their division. The function should handle cases where the denominator is zero by returning `None`. The code should start with:
```python
def divide_floats(num1: float, num2: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def divide_floats(num1: float, num2: float) -> float:
"""
This function takes two float numbers as input and returns their division.
If the denominator is zero, it returns None to handle the zero division error.
Paramet... |
code_exercise_27k | 1,598 | Write a Python function named `floor_float` that takes a float number as input and returns the largest integer less than or equal to the input number. The function should handle both positive and negative float numbers. The code should start with:
```python
import math
def floor_float(num: float) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import math
def floor_float(num: float) -> int:
"""
Returns the largest integer less than or equal to the given float number.
Args:
num (float): The input number for which to find the floor value.
Returns:
... |
code_exercise_27k | 1,599 | Write a Python function named `ceil_float` that takes a float number as input and returns the smallest integer greater than or equal to the input number. The function should handle both positive and negative float numbers. The code should start with:
```python
import math
def ceil_float(num: float) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import math
def ceil_float(num: float) -> int:
"""
Returns the smallest integer greater than or equal to the given float number.
Args:
num (float): The input number for which to find the ceiling value.
Returns... |
code_exercise_27k | 1,600 | Write a Python function named `truncate_float` that takes a float number as input and returns the integer part of the input number. The function should handle both positive and negative float numbers correctly. The code should start with:
```python
def truncate_float(num: float) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def truncate_float(num: float) -> int:
"""
Truncates a float number to its integer part.
Args:
num (float): The input number to be truncated.
Returns:
int: The integer part of the input number.
"""
... |
code_exercise_27k | 1,602 | Write a Python function named `find_maximum` that takes a list of float numbers as input and returns the maximum value from the list. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_maximum(numbers: List[float]) -> Optional[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_maximum(numbers: List[float]) -> Optional[float]:
"""
Find the maximum value from a list of float numbers.
Args:
numbers (List[float]): A list of float numbers.
Retur... |
code_exercise_27k | 1,603 | Write a Python function named `find_minimum` that takes a list of float numbers as input and returns the minimum value from the list. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_minimum(numbers: List[float]) -> Optional[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_minimum(numbers: List[float]) -> Optional[float]:
"""
Find the minimum value from a list of float numbers.
Args:
numbers (List[float]): A list of float numbers.
Retur... |
code_exercise_27k | 1,605 | Write a Python function named `is_even` that takes a float number as input and returns `True` if the number is even, and `False` otherwise. The function should handle both integer and non-integer float inputs. For non-integer floats, the function should return `False`.
The code should start with:
```python
def is_even... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_even(num: float) -> bool:
"""
Determines if a given float number is even.
This function checks if the input float number is an integer and if it is even.
If the number is not an integer, it returns False.
Ar... |
code_exercise_27k | 1,607 | Write a Python function named `calculate_square_root` that takes a float number as input and returns its square root. The function should handle both positive and zero inputs. For negative inputs, the function should return `None` to indicate that the square root of a negative number is not a real number.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_square_root(num: float) -> float:
"""
Calculate the square root of a given float number.
This function takes a float number as input and returns its square root.
If the input number is negativ... |
code_exercise_27k | 1,608 | Write a Python function named `calculate_power` that takes two float numbers as input: `base` and `exponent`. The function should return the result of raising the `base` to the power of the `exponent`. The function should handle both positive and negative exponents, as well as special cases like raising to the power of... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_power(base: float, exponent: float) -> float:
"""
Calculate the result of raising the base to the power of the exponent.
Parameters:
base (float): The base number.
exponent (float): The exponent number... |
code_exercise_27k | 1,609 | Write a Python function named `calculate_percentage` that takes two float numbers as input: `part` and `whole`. The function should return the percentage representation of the `part` with respect to the `whole`. The function should handle cases where the `whole` is zero by returning `None` to avoid division by zero err... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_percentage(part: float, whole: float) -> float:
"""
Calculate the percentage representation of the part with respect to the whole.
Args:
part (float): The part number.
whole (float): The whole ... |
code_exercise_27k | 1,611 | Write a Python function named `check_integer_part` that takes a float number as input and returns `True` if the integer part of the number is greater than 0, and `False` otherwise. The function should handle both positive and negative float numbers. The code should start with:
```python
def check_integer_part(num: floa... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_integer_part(num: float) -> bool:
"""
Checks if the integer part of a given float number is greater than 0.
Parameters:
num (float): The input number whose integer part needs to be checked.
Returns:
b... |
code_exercise_27k | 1,613 | Write a Python function named `convert_to_string` that takes a float number as input and converts it to a string representation. The function should return the string representation of the float number. Additionally, ensure that the function handles edge cases such as zero, negative numbers, and very large or very smal... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_string(num: float) -> str:
"""
Converts a float number to its string representation.
Args:
num (float): The input number to be converted to a string.
Returns:
str: The string representati... |
code_exercise_27k | 1,614 | Write a Python function named `check_positive` that takes a float number as input and returns `True` if the number is positive, and `False` otherwise. The function should handle edge cases such as zero and negative numbers correctly.
The code should start with:
```python
def check_positive(num: float) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def check_positive(num: float) -> bool:
"""
Check if the given float number is positive.
Parameters:
num (float): The input number to be checked.
Returns:
bool: True if the number is positive, False otherwise.
... |
code_exercise_27k | 1,615 | Write a Python function named `check_negative` that takes a float number as input and returns `True` if the number is negative, and `False` otherwise. The function should handle edge cases such as zero and positive numbers correctly.
The code should start with:
```python
def check_negative(num: float) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def check_negative(num: float) -> bool:
"""
Determines if the given float number is negative.
Parameters:
num (float): The input number to be checked.
Returns:
bool: True if the number is negative, False otherw... |
code_exercise_27k | 1,616 | Write a Python function named `is_zero` that takes a float number as input and returns `True` if the number is zero (considering floating-point precision issues), and `False` otherwise. The function should handle small deviations from zero due to floating-point arithmetic.
The code should start with:
```python
def is_... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_zero(num: float) -> bool:
"""
Check if a given float number is zero, considering floating-point precision issues.
Parameters:
num (float): The input number to check.
Returns:
bool: True if the number is ... |
code_exercise_27k | 1,617 | Write a Python function named `calculate_difference` that takes two float numbers as input: `num1` and `num2`. The function should return the absolute difference between `num1` and `num2`. The function should be robust and handle any valid float inputs. The code should start with:
```python
def calculate_difference(num... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_difference(num1: float, num2: float) -> float:
"""
Calculate the absolute difference between two float numbers.
This function takes two float numbers as input and returns the absolute difference between them.
... |
code_exercise_27k | 1,618 | Write a Python function named `check_greater` that takes two float numbers as input: `num1` and `num2`. The function should return `True` if `num1` is greater than `num2`, and `False` otherwise. The function should be designed to handle any float inputs, including edge cases such as negative numbers, zero, and very lar... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_greater(num1: float, num2: float) -> bool:
"""
This function takes two float numbers as input: num1 and num2. It returns True if num1 is greater than num2, and False otherwise.
Parameters:
num1 (float): The fi... |
code_exercise_27k | 1,619 | Write a Python function named `check_smaller` that takes two float numbers as input: `num1` and `num2`. The function should return `True` if `num1` is smaller than `num2`, and `False` otherwise. The function should be designed to handle any float inputs, including edge cases such as negative numbers, zero, and very lar... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_smaller(num1: float, num2: float) -> bool:
"""
This function takes two float numbers as input: num1 and num2. It returns True if num1 is smaller than num2, and False otherwise.
Parameters:
num1 (float): The fi... |
code_exercise_27k | 1,620 | Write a Python function named `check_equal_with_tolerance` that takes two float numbers as input: `num1` and `num2`, and a tolerance value `epsilon`. The function should return `True` if the absolute difference between `num1` and `num2` is less than or equal to `epsilon`, and `False` otherwise. The function should hand... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_equal_with_tolerance(num1: float, num2: float, epsilon: float) -> bool:
"""
Checks if two float numbers are equal within a given tolerance.
This function compares two float numbers, num1 and num2, and returns True... |
code_exercise_27k | 1,623 | Write a Python function named `calculate_average_ignore_none` that takes a list of float numbers as input. The function should calculate the average of those numbers, ignoring any `None` values in the list. If all values in the list are `None`, the function should return `None`.
The code should start with:
```python
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def calculate_average_ignore_none(numbers: List[Optional[float]]) -> Optional[float]:
"""
Calculate the average of a list of float numbers, ignoring any None values.
Args:
numbers ... |
code_exercise_27k | 1,627 | Write a Python function named `is_prime` that takes a float number as input. The function should return `True` if the number is a prime number, and `False` otherwise. The function should handle both integer and non-integer float inputs. For non-integer float inputs, the function should return `False`.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def is_prime(num: float) -> bool:
"""
Determines if the given float number is a prime number.
Args:
num (float): The input number to check for primality.
Returns:
bool: True if the number i... |
code_exercise_27k | 1,629 | Write a Python function named `calculate_combinations` that takes two non-negative integers as input: `n` and `r`. The function should calculate and return the number of combinations of `n` items taken `r` at a time. The function should use the mathematical formula for combinations, which is given by:
\[ C(n, r) = \fr... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_combinations(n: int, r: int) -> int:
"""
Calculate the number of combinations of n items taken r at a time.
Args:
n (int): The total number of items.
r (int): The number of items t... |
code_exercise_27k | 1,630 | Write a Python function named `calculate_permutations` that takes two non-negative integers as input: `n` and `r`. The function should calculate and return the number of permutations of `n` items taken `r` at a time. The function should handle edge cases such as when `r` is greater than `n` or when either `n` or `r` is... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_permutations(n: int, r: int) -> int:
"""
Calculate the number of permutations of n items taken r at a time.
Args:
n (int): The total number of items.
r (int): The number of items t... |
code_exercise_27k | 1,632 | Write a Python function named `filter_positive_numbers` that takes a list of float numbers as input. The function should return a new list containing only the positive numbers from the input list. The function should handle an empty list and return an empty list in that case. 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 filter_positive_numbers(numbers: List[float]) -> List[float]:
"""
Filters out the positive numbers from a given list of float numbers.
Args:
numbers (List[float]): A list of float number... |
code_exercise_27k | 1,636 | Write a Python function named `sort_numbers` that takes a list of float numbers as input. The function should return a new list containing the numbers from the input list in ascending order. The function should handle an empty list and lists with duplicate numbers. The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_numbers(numbers: List[float]) -> List[float]:
"""
Sorts a list of float numbers in ascending order and returns a new list.
Args:
numbers (List[float]): A list of float numbers to be... |
code_exercise_27k | 1,637 | Write a Python function named `reverse_numbers` that takes a list of float numbers as input. The function should return a new list containing the numbers from the input list in reverse order. The function should handle cases where the input list is empty or contains only one element.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_numbers(numbers: List[float]) -> List[float]:
"""
Reverses the order of the float numbers in the input list.
Args:
numbers (List[float]): A list of float numbers to be reversed.
... |
code_exercise_27k | 1,638 | Write a Python function named `count_numbers` that takes a list of float numbers as input. The function should return the count of numbers in the input list. The function should handle cases where the input list is empty or contains non-float elements. If the input list contains non-float elements, the function should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_numbers(numbers: List[float]) -> int:
"""
Counts the number of float numbers in the input list.
Args:
numbers (List[float]): A list of float numbers. Non-float elements are ignored... |
code_exercise_27k | 1,640 | Write a Python function named `remove_duplicates` that takes a list of float numbers as input. The function should return a new list containing only the unique numbers from the input list, maintaining the original order of the first occurrence of each number. The function should not use any external libraries or built-... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(numbers: List[float]) -> List[float]:
"""
Removes duplicates from a list of float numbers while maintaining the order of the first occurrence of each number.
Args:
numb... |
code_exercise_27k | 1,645 | Write a Python function named `calculate_area_of_triangle` that takes two float numbers as input: `base` and `height`. The function should calculate and return the area of a triangle using the formula: `area = (1/2) * base * height`. The function should be well-documented with a docstring that explains its purpose, par... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_area_of_triangle(base: float, height: float) -> float:
"""
Calculate the area of a triangle given its base and height.
Args:
base (float): The base length of the triangle.
height (float): The h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.