mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
24125e3b7d
commit
67ef6182fe
@ -1,83 +1,89 @@
|
||||
def is_upper(string):
|
||||
"""
|
||||
Check if all characters in the string are uppercase letters.
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are uppercase letters, False otherwise.
|
||||
"""
|
||||
return all(ord(char) >= 65 and ord(char) <= 90 for char in string)
|
||||
|
||||
|
||||
def is_lower(string):
|
||||
"""
|
||||
Check if all characters in the string are lowercase letters.
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are lowercase letters, False otherwise.
|
||||
"""
|
||||
return all(ord(char) >= 97 and ord(char) <= 122 for char in string)
|
||||
|
||||
|
||||
def is_alpha(string):
|
||||
"""
|
||||
Check if all characters in the string are alphabetical (letters).
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are letters, False otherwise.
|
||||
"""
|
||||
return all(char.isalpha() for char in string)
|
||||
|
||||
|
||||
def is_alnum(string):
|
||||
"""
|
||||
Check if all characters in the string are alphanumeric (letters or digits).
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are letters or digits, False otherwise.
|
||||
"""
|
||||
return all(char.isalnum() for char in string)
|
||||
|
||||
|
||||
def is_decimal(string):
|
||||
"""
|
||||
Check if all characters in the string are decimal digits.
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are decimal digits, False otherwise.
|
||||
"""
|
||||
return all(char.isdigit() for char in string)
|
||||
|
||||
|
||||
def is_space(string):
|
||||
"""
|
||||
Check if all characters in the string are whitespace characters.
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if all characters in the string are whitespace characters, False otherwise.
|
||||
"""
|
||||
return all(char.isspace() for char in string)
|
||||
|
||||
|
||||
def is_title(string):
|
||||
"""
|
||||
Check if the string is in title case (first letter of each word is capital).
|
||||
|
||||
|
||||
Args:
|
||||
string (str): The input string.
|
||||
|
||||
|
||||
Returns:
|
||||
bool: True if the string is in title case, False otherwise.
|
||||
"""
|
||||
return string.istitle()
|
||||
return string.istitle()
|
||||
|
Loading…
x
Reference in New Issue
Block a user