AMP

Chapter 8: Strings and String Manipulation — Online MCQ Test

COMPUTER SCIENCE · CLASS 12th · Tamil Nadu State Board
Practice Chapter 8: Strings and String Manipulation with a free chapter-wise online MCQ test. This chapter covers: This chapter covers character sequences and text processing in Python. Students explore string immutability slicing operations formatting methods string operators and built-in func.... AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter 8: Strings and String Manipulation — Important Questions & Answers

Which of the following best describes a string in Python?
  • A. A mutable sequence of integers
  • B. An immutable sequence of characters
  • C. A collection of key-value pairs
  • D. A set of unordered elements
Answer: B. An immutable sequence of characters
In Python, a string is a sequence of characters and it cannot be changed after creation, so it is immutable.
What is the output of: print('Tamil' + 'Nadu') ?
  • A. Tamil Nadu
  • B. TamilNadu
  • C. Tamil+Nadu
  • D. Tamil Nadu
Answer: B. TamilNadu
The + operator concatenates strings directly without adding a space.
What will be the result of: 'Computer'[1:4] ?
  • A. Com
  • B. omp
  • C. mput
  • D. Comu
Answer: B. omp
String slicing starts at index 1 and goes up to, but does not include, index 4. So the characters are o, m, p.
Which of the following expressions will produce the string 'ana' from 'banana'?
  • A. 'banana'[1:4]
  • B. 'banana'[1:5]
  • C. 'banana'[3:6]
  • D. 'banana'[2:5]
Answer: D. 'banana'[2:5]
Index 2 to 4 gives the characters a, n, a because the end index is excluded in slicing.
If s = 'Computer Science', which of the following returns 'Science'?
  • A. s[8:]
  • B. s[:8]
  • C. s[9:16]
  • D. s[-7:]
Answer: D. s[-7:]
The word 'Science' has 7 letters at the end of the string, so s[-7:] correctly extracts it.