Chapter 14 Strings
Chapter 14 Strings
STRINGS
XI
Computer Science (083)
Board : CBSE
Unit 2:
Computational Thinking and Programming
Courtesy CBSE
Unit II
Computational Thinking and Programming
(60 Theory periods 45 Practical Periods)
Prepared by
Praveen M Jigajinni
DCSc & Engg, PGDCA,ADCA,MCA.MSc(IT),Mtech(IT),MPhil (Comp. Sci)
Backward Indexing
Forward Indexing
STRINGS – Programming Example
STRINGS - Example
>>> name1="computer"
>>> name2=name1[3:5]
>>>name2
pu String Slicing
String Methods
String Methods
object.method(arguments)
For Example: the first position
>>>name=“Classic” where “s” appears
>>>name.find(“s”)
3
String object String Method Method Argument
Built in Methods
1. capitalize() Method
Centered string
12. zfill() Method
Filling Zeros
13. find() Method
>>>name1=“praveen“
>>>name1.count(“e”)
2
>>>name1=“praveen“
>>>name1.startswith(“a”)
False
>>>name1=“praveen“
>>>name1.endswith(“en”)
True
>>>str(576)
‘576’
>>>len(“Praveen”)
7
>>>max(“Praveen”)
v
>>>min(“Praveen”)
P
>>ord(“a”)
97
>>chr(97)
‘a’
1. What is string? 02
2. What is forward indexing and back
word indexing? 03
3. Explain any 5 string built in methods
10
4. What are character methods? Explain
in detail 05
Thank You