Class 12 : Python String Inbuilt Functions

isalpha()

This method helps us to check whether all the characters in string are alphabet letters (a-z,A-Z) or not .
Example of characters that are not alphabet letters:
(space)!#%&? etc.
Syntax
string.isalpha()

Returns “True” if all the characters in the text are alphabets otherwise returns “False”.

Example:

#isalpha()
n="hello"
print(n.isalpha())
n="hello123"
print(n.isalpha())
x=n.isalpha()
print(x)

Output:

True
False
False
>>>

islower()

This method helps us to check whether all the characters in string are lower case alphabet letters (a-z) or not .
Syntax
string.islower()

Returns “True” if all the characters in the text are lower case alphabets otherwise returns “False”.

Example:

#islower()
n="hello"
print(n.islower())
n="Hello"
print(n.islower())
x=n.islower()
print(x)

Output:

True
False
False
>>>

isupper()

This method helps us to check whether all the characters in string are upper case alphabet letters (A-Z) or not .
Syntax
string.isupper()

Returns “True” if all the characters in the text are upper case alphabets otherwise returns “False”.

Example:

#isupper()
 n="hello"
 print(n.isupper())
 n="HELLO"
 print(n.isupper())
 x=n.isupper()
 print(x)

Output:

False
True
True
>>>

isdigit()

This method helps us to check whether all the characters in string are digits (0-9) or not .
Syntax
string.isdigit()

Returns “True” if all the characters in the text are digits otherwise returns “False”.

Example:

#isdigit()
 n="12345"
 print(n.isdigit())
 n="HELLO12"
 print(n.isdigit())
 x=n.isdigit()
 print(x)

Output:

True
False
False
>>>

Python String Inbuilt Function       Python Math Inbuilt Function       Python Data and Time Inbuilt Functions       Python Random Module Functions

Number Of Visitors

0238272