Notes · Class 11 · CBSE · Science Computer Science

Strings notes

Revision notes for the chapter: the key points, definitions and exam tips to remember.

A string is an ordered, immutable sequence of characters.

CREATING AND ACCESSING

  • Single, double or triple quotes.
  • Indexing: s[0] first, s[-1] last.
  • Slicing: s[start:stop:step]; s[::-1] reverses.

OPERATIONS

  • Concatenation (+), repetition (*), membership (in), comparison.
  • Traversal with a for loop.
  • Strings are immutable: s[0] = 'x' gives an error.

COMMON METHODS

  • len(), title(), lower(), upper(), count(), find() (−1 if not found), index() (error if not found).
  • startswith(), endswith(), isalnum(), isalpha(), isdigit(), isspace(), islower(), isupper().
  • strip(), lstrip(), rstrip(), replace(), split(), join(), partition().

COMMON PROGRAMS

  • Count vowels, check palindrome, reverse a string, count words.
Memory hook: "Strings are read-only: slice and rebuild, don't edit in place."

Strings: practice questionsStrings cheat sheet

More Class 11 · CBSE · Science Computer Science notes

Practise Strings

Sign up free to practise the full chapter after revising. Questions you get wrong come back until you've mastered them.

Start practising free

Free to start · No credit card needed