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

Class XI Python Strings Complete CBSE Notes

This document provides an overview of strings in Python, including their definition, key features, and various string methods with examples. It covers important concepts such as immutability, indexing, slicing, and common operations like concatenation and repetition. Additionally, it includes practice questions, MCQs, and case-based questions for better understanding and application of string manipulation in Python.

Uploaded by

goku77319
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)
1 views2 pages

Class XI Python Strings Complete CBSE Notes

This document provides an overview of strings in Python, including their definition, key features, and various string methods with examples. It covers important concepts such as immutability, indexing, slicing, and common operations like concatenation and repetition. Additionally, it includes practice questions, MCQs, and case-based questions for better understanding and application of string manipulation in Python.

Uploaded by

goku77319
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

Class XI Computer Science / Informatics Practices

Chapter: STRINGS IN PYTHON - Complete CBSE


Notes
1. Definition
A string is a sequence of characters enclosed in single, double or triple quotes. Strings are
immutable.

2. Key Features
• Ordered sequence of characters
• Positive and negative indexing
• Slicing supported
• Immutable data type
• Supports concatenation, repetition and membership operators

3. String Methods
Method Syntax Example Output

len() len(s) len('Python') 6


lower() [Link]() 'HeLLo' hello
upper() [Link]() 'hello' HELLO
title() [Link]() 'hello world' Hello World
count() [Link]('l') 'Hello' 2
find() [Link]('th') 'Python' 2
replace() [Link](a,b) Hello→Hi Hi
split() [Link]() 'A B' ['A','B']
join() '-'.join(s) ABC A-B-C
partition() [Link]('is') India is ('India','is','')
strip() [Link]() ' Hi ' Hi
startswith() [Link]('Py') Python True
endswith() [Link]('on') Python True
isalpha() [Link]() Python True
isdigit() [Link]() 123 True
isalnum() [Link]() ABC123 True
islower() [Link]() python True
isupper() [Link]() PYTHON True
istitle() [Link]() Hello World True
isspace() [Link]() ' ' True
4. Syntax & Examples
• Indexing: s='Python' → s[0]='P', s[-1]='n'
• Slicing: s[1:4] → yth
• Concatenation: 'Hello'+'World' → HelloWorld
• Repetition: 'Hi'*3 → HiHiHi
• Membership: 'Py' in 'Python' → True
• Reverse: s[::-1]

5. Important Exam Notes


✓ Strings are immutable.
✓ find() returns -1 if substring is absent.
✓ split() returns a list.
✓ join() joins iterable elements into a string.
✓ replace() returns a new string.

6. Practice Questions
1. Write a program to reverse a string.
2. Count vowels in a string.
3. Check whether a string is palindrome.
4. Count frequency of a character.
5. Differentiate indexing and slicing.

7. MCQs
1. Which method converts to uppercase? (a) upper() (b) lower() (c) title() (d) split() Answer: a
2. Which operator repeats a string? Answer: *
3. Which method returns a list? Answer: split()
4. Strings are: (a) Mutable (b) Immutable ✔
5. len('Python') = 6

8. Assertion-Reason
A: Strings are immutable.
R: Characters of a string cannot be modified using indexing.
Answer: Both A and R are true, and R is the correct explanation.

9. Case-Based Questions
A student enters 'Computer Science'. Write code to count spaces, convert it to uppercase, and
replace 'Science' with 'Programming'.
Answer:
s='Computer Science'
print([Link](' '))
print([Link]())
print([Link]('Science','Programming'))

You might also like