Oct 6, 2025
This lecture covers three important Python string methods: isalpha(), isnumeric(), and isalnum(), explaining their purpose, syntax, and behavior with examples. A homework problem is also provided for practice.
isalpha() returns True if all characters in a string are alphabetic (A-Z, a-z), with no spaces or other characters.string.isalpha()"hello2".isalpha() returns False because '2' is not an alphabet."helloIAmJustpreet".isalpha() returns True since all characters are letters."hello I am justpreet".isalpha() returns False due to spaces.isnumeric() returns True if all characters in a string are numeric digits (0-9), no dots, minus signs, or other symbols allowed.string.isnumeric()"2332324".isnumeric() returns True."3.14159".isnumeric() returns False because the dot is not numeric."2/4".isnumeric() returns False as '/' is not a digit."-3425".isnumeric() returns False because '-' is not a digit.isalnum() returns True if all characters in a string are either alphabetic or numeric (no spaces or special characters).string.isalnum()"justpreet20".isalnum() returns True (letters and digits only)."22324242".isalnum() returns True (digits only)."JustBreathe".isalnum() returns True (letters only)."Just preet".isalnum() returns False due to the space.isalpha(), isnumeric(), and isalnum() methods before checking in Python.