Skip to main content
Chapter 8 of 11
NCERT Solutions

Strings

CBSE · Class 11 · Computer Science

NCERT Solutions for Strings — CBSE Class 11 Computer Science.

39 questions80 flashcards5 concepts

Interactive on Super Tutor

Studying Strings? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for ncert solutions and more.

1,000+ Class 11 students started this chapter today

7 Questions Solved · 2 Sections

4 worked solutions below. Unlock all 7 free in Super Tutor

EXERCISE

1Consider the following string mySubject:

mySubject = "Computer Science"

What will be the output of the following string operations :
Show solution
i. `Computer Science`

ii. `Scien`

iii. `Cmue cc`

iv. `e`

v. `Computer ScienceComputer Science`

vi. `ecneiS retupmoC`

vii. `Computer Science`

viii. `cOMPUTER sCIENCE`

ix. `True`

x. `False`

Not sure why a step works? check your working in Super Tutor

2Consider the following string myAddress:

myAddress = "WZ-1,New Ganga Nagar,New Delhi"

What will be the output of following string operations :
Show solution
i. `wz-1,new ganga nagar,new delhi`

ii. `WZ-1,NEW GANGA NAGAR,NEW DELHI`

iii. `2`

iv. `5`

v. `21`

vi. `['WZ-1', 'New Ganga Nagar', 'New Delhi']`

vii. The book text appears to have a printing error in `split(' '')`. Interpreting it as splitting by space, the output is `['WZ-1,New', 'Ganga', 'Nagar,New', 'Delhi']`.

viii. `WZ-1,Old Ganga Nagar,Old Delhi`

ix. `('WZ-1', ',', 'New Ganga Nagar,New Delhi')`

x. `ValueError: substring not found`

Not sure why a step works? check your working in Super Tutor

PROGRAMMING PROBLEMS

1Write a program to input line(s) of text from the user until enter is pressed. Count the total number of characters in the text (including white spaces), total number of alphabets, total number of digits, total number of special symbols and total number of words in the given text. (Assume that each word is separated by one space).Show solution
```python
text = input("Enter text: ")

chars = len(text)
alphabets = 0
digits = 0
special = 0
words = 0

for ch in text:
if ch.isalpha():
alphabets += 1
elif ch.isdigit():
digits += 1
elif ch != ' ':
special += 1

if text != '':
words = text.count(' ') + 1

print("Total characters:", chars)
print("Total alphabets:", alphabets)
print("Total digits:", digits)
print("Total special symbols:", special)
print("Total words:", words)
```

Not sure why a step works? check your working in Super Tutor

2Write a user defined function to convert a string with more than one word into title case string where string is passed as parameter. (Title case means that the first letter of each word is capitalised)Show solution
```python
def titleCase(st):
newstr = ''
word = ''
for ch in st:
if ch == ' ':
newstr += word.capitalize() + ' '
word = ''
else:
word += ch
newstr += word.capitalize()
return newstr

st = input("Enter a string: ")
print(titleCase(st))
```

Not sure why a step works? check your working in Super Tutor

3Write a function deleteChar() which takes two parameters one is a string and other is a character. The function should create a new string after deleting all occurrences of the character from the string and return the new string.
4Input a string having some digits. Write a function to return the sum of digits present in this string.
5Write a function that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence.

3 more solved questions in Strings

Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Strings for CBSE Class 11 Computer Science?
Strings covers several key topics that are frequently asked in CBSE Class 11 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Strings — CBSE Class 11 Computer Science?
Understand the core concepts first, then work through the 39 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Strings Class 11 Computer Science?
This page has free step-by-step NCERT Solutions for every exercise question in Strings (CBSE Class 11 Computer Science) — written the way examiners award marks: given, formula, working, answer.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Strings chapter — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 11 Computer Science.