Advertisement
# Signature of isdecimal() method
isdecimal()
# Python - Method isdecimal() Example
# Creating the first string
s1 = ('Hey you, be happy!')
# Printing the first string
print('The first string : ', s1)
# Calling the isdecimal() method on first string object
print('isdecimal() method on first string : ', s1.isdecimal())
# Creating the second string
s2 = ('The first 8 planets')
# Printing the second string
print('The second string : ', s2)
# Calling the isdecimal() method on second string object
print('isdecimal() method on second string : ', s2.isdecimal())
# Creating the third string
s3 = ('4...1..6..1!')
# Printing the third string
print('The third string : ', s3)
# Calling the isdecimal() method on third string object
print('isdecimal() method on third string : ', s3.isdecimal())
# Creating the fourth string
s4 = ('862331')
# Printing the fourth string
print('The fourth string : ', s4)
# Calling the isdecimal() method on fourth string object
print('isdecimal() method on fourth string : ', s4.isdecimal())
The first string : Hey you, be happy!
isdecimal() method on first string : False
The second string : The first 8 planets
isdecimal() method on second string : False
The third string : 4...1..6..1!
isdecimal() method on third string : False
The fourth string : 862331
isdecimal() method on fourth string : True
Advertisement
# Python - Method isdecimal() Example
# Calling isdecimal() method on a string of decimal values with a comma
print('75,99'.isdecimal())
# Calling isdecimal() method on a string repesenting a specific currency value
print('8.99$'.isdecimal())
# Calling isdecimal() method on a string representing a floating value
print('82.99'.isdecimal())
# Calling isdecimal() method on a string of all decimal values except a !
print('1000!'.isdecimal())
# Calling isdecimal() method of all decimal values
print('011101'.isdecimal())
False
False
False
False
True
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement