Advertisement
# Signature of isnumeric() method
isnumeric()
# Python - Method isnumeric() Example
# Creating the first string
s1 = ('I Love Minions')
# Printing the first string
print('The first string : ', s1)
# Calling the isnumeric() method on first string object
print('isnumeric() method on first string : ', s1.isnumeric())
# Creating the second string
s2 = ('It took me 7 days to reach the summit')
# Printing the second string
print('The second string : ', s2)
# Calling the isnumeric() method on second string object
print('isnumeric() method on second string : ', s2.isnumeric())
# Creating the third string
s3 = ('3...2...1!')
# Printing the third string
print('The third string : ', s3)
# Calling the isnumeric() method on third string object
print('isnumeric() method on third string : ', s3.isnumeric())
# Creating the fourth string
s4 = ('463321')
# Printing the fourth string
print('The fourth string : ', s4)
# Calling the isnumeric() method on fourth string object
print('isnumeric() method on fourth string : ', s4.isnumeric())
The first string : I Love Minions
isnumeric() method on first string : False
The second string : It took me 7 days to reach the summit
isnumeric() method on second string : False
The third string : 3...2...1!
isnumeric() method on third string : False
The fourth string : 463321
isnumeric() method on fourth string : True
Advertisement
# Python - Method isnumeric() Example
# Calling isnumeric() method on a string of digits with a comma
print('123,456'.isnumeric())
# Calling isnumeric() method on a string repesenting a specific currency value
print('5.43$'.isnumeric())
# Calling isnumeric() method on a string representing a floating value
print('12.99'.isnumeric())
# Calling isnumeric() method on a string of all digits except a !
print('999!'.isnumeric())
# Calling isnumeric() method of all binary digits
print('01011'.isnumeric())
False
False
False
False
True
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement