0% found this document useful (0 votes)
15 views2 pages

Python String Functions Notes Neat

The document provides notes on various Python string functions, detailing their uses and examples. Functions include isalnum(), isalpha(), isdigit(), lower(), islower(), isupper(), upper(), title(), swapcase(), len(), capitalize(), center(), find(), count(), ord(), chr(), and the 'in' operator. Each function is explained with its purpose and a corresponding example.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Python String Functions Notes Neat

The document provides notes on various Python string functions, detailing their uses and examples. Functions include isalnum(), isalpha(), isdigit(), lower(), islower(), isupper(), upper(), title(), swapcase(), len(), capitalize(), center(), find(), count(), ord(), chr(), and the 'in' operator. Each function is explained with its purpose and a corresponding example.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Bharani Park Matric Hr Sec School

Computer Science – Python String Functions (Notes)

isalnum()
Use: Checks if string contains only letters and numbers
Example: 'SaveEarth'.isalnum() → True

isalpha()
Use: Checks if string contains only letters
Example: 'Python'.isalpha() → True

isdigit()
Use: Checks if string contains only digits
Example: '1234'.isdigit() → True

lower()
Use: Converts string to lowercase
Example: 'HELLO'.lower() → hello

islower()
Use: Checks if string is lowercase
Example: 'hello'.islower() → True

isupper()
Use: Checks if string is uppercase
Example: 'HELLO'.isupper() → True

upper()
Use: Converts string to uppercase
Example: 'hello'.upper() → HELLO

title()
Use: Converts first letter of each word to capital
Example: 'education department'.title() → Education Department

swapcase()
Use: Swaps uppercase to lowercase and vice versa
Example: 'TaMiL'.swapcase() → tAmIl

len()
Use: Returns length of string
Example: len('Python') → 6

capitalize()
Use: Capitalizes first letter
Example: 'chennai'.capitalize() → Chennai

center()
Use: Centers string with given width
Example: 'Welcome'.center(15,'*') → ****Welcome****

find()
Use: Finds index of substring
Example: 'mammals'.find('ma') → 0

count()
Use: Counts occurrences of substring
Example: 'banana'.count('a') → 3

ord()
Use: Returns ASCII value of character
Example: ord('A') → 65

chr()
Use: Returns character from ASCII value
Example: chr(65) → A

in operator
Use: Checks if substring is present
Example: 'city' in 'chennai city' → True

You might also like