100% found this document useful (1 vote)
250 views

String MCQ

This document contains 10 multiple choice questions that test string operations and methods in Python. Some questions test immutable nature of strings, string slicing, string methods like find(), title(), isalpha(), and reversing a string. The correct answers are d, c, a, b, b, b, a, b, a, a respectively.

Uploaded by

Mafnitha KK
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
250 views

String MCQ

This document contains 10 multiple choice questions that test string operations and methods in Python. Some questions test immutable nature of strings, string slicing, string methods like find(), title(), isalpha(), and reversing a string. The correct answers are d, c, a, b, b, b, a, b, a, a respectively.

Uploaded by

Mafnitha KK
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

STRING MCQ

1.What arithmetic operators cannot be used with strings?

a) +
b) –
c) *
d) All of the mentioned

2.What is the output of the given below program?


string = "Know Program"
print(string[:5] + "Python”

a) Know
b) Know Program
c) Know Python
d) None of these

3.Strings are immutable in Python, which means a string cannot be modified.

a) True
b) False

4.To return the length of string s what command do we execute?

a) s.len()
b) len(s)
c) size(s)
d) s.size()

5.Which method should I use to convert String “Python programming is fun” to “Python
Programming Is Fun”?

a) capitalize()
b) title()
c) istitle()
d) upper()

6. To check whether string s1 contains another string s2, use __.


a) s1.contains(s2)
b) s2 in s1
c) s1.contains(s2)
d) si.in(s2)

7.Find the output of the given Python program?


print("Know Program".find("o"))

a) 7
b) 2
c) 2, 7
d) None of these

8.How would you extract 'World' from the string 'Hello, World!'?
a) 'Hello, World!'[7:11]
b) 'Hello, World!'[6:11]
c) 'Hello, World!'[7:12]
d) 'Hello, World!'[6:12]

9.What is the output of 'Python'.isalpha()?


a) True
b) False
c) 1
d) 0

10.Which of the following will return the string 'Python' backward?


a) 'Python'[::-1]
b) 'Python'.reverse()
c) reverse('Python')
d) 'Python'[-1:]

You might also like