0% found this document useful (0 votes)
5 views3 pages

Class8 String Methods1

The document provides examples of various string manipulation methods in Python, including capitalize(), count(), islower(), isupper(), swapcase(), istitle(), startswith(), and endswith(). Each method is demonstrated with sample strings and their outputs. The document serves as a guide for understanding how to manipulate and analyze strings using these built-in functions.
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)
5 views3 pages

Class8 String Methods1

The document provides examples of various string manipulation methods in Python, including capitalize(), count(), islower(), isupper(), swapcase(), istitle(), startswith(), and endswith(). Each method is demonstrated with sample strings and their outputs. The document serves as a guide for understanding how to manipulate and analyze strings using these built-in functions.
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
You are on page 1/ 3

In [1]: # captialize() - to make 1st letter from lowercase into uppercase

a="hey buddies"
print(a.capitalize())

Hey buddies

In [2]: # captialize() - make no change in case of integer


age="40 is my age"
print(age.capitalize())

40 is my age

In [10]: #count() - it will count how many times the specified words/letters accurs in the v
b= "welcome to Gurukula"
print(b.count("welcome"))
print(b.count("e"))
print(b.count("u"))
print(b.count("u",0,15))
print(b.count("u",0,17))

1
2
3
2
3

In [12]: #islower() - checks the strings are in lowercase and print true or false and lowe
c="pYthon for Toddlers"
d="pytHon for TODDdlers"
e="python for toddlers"
print(c.islower())
print(d.islower())
print(e.islower())

False
False
True

In [13]: #islower() - checks the all strings are in lowercase and print true or false and
c="pYthon for Toddlers"
d="pytHon for TODDdlers"
e="python for toddlers"
print(c.lower())
print(d.lower())
print(e.lower())

python for toddlers


python for todddlers
python for toddlers

In [14]: #isupper() - checks the all strings are in uppercase and print true or false and
c="pYthon for Toddlers"
d="pytHon for TODDdlers"
e="PYTHON FOR TODDLERS"
print(c.isupper())
print(d.isupper())
print(e.isupper())

False
False
True

In [15]: #isupper() - checks the all strings are in uppercase and print true or false and
c="pYthon for Toddlers"
d="pytHon for TODDdlers"
e="PYTHON FOR TODDLERS"
print(c.upper())
print(d.upper())
print(e.upper())

PYTHON FOR TODDLERS


PYTHON FOR TODDDLERS
PYTHON FOR TODDLERS

In [17]: #SWAPCASE() -it converts upper into lowercase and viceversa


f="PYTHON for TOOddlers"
print(f.swapcase())

python FOR tooDDLERS

In [19]: #istittle()- checks whether first letter of every words are captitalized or not and
g="welcome to gurukula"
print(g.istitle())
print(g.title())

False
Welcome To Gurukula

In [27]: #startswith()- cheks whether the mentioned string is the starting strings or not
var="hey how are you??"
print(var.startswith("hey"))
print(var.startswith("how"))
print(var.startswith("h"))
print(var.startswith("he"))

True
False
True
True

In [29]: #endswith()- cheks whether the mentioned string is the ending strings or not
var="hey how are you??"
print(var.endswith("you"))
print(var.endswith("??"))
print(var.endswith("?"))
print(var.endswith("."))

False
True
True
False

In [ ]: #replace()
In [ ]: #find()

You might also like