Python String MCQ – 1

Q1) Which operation cannot be performed on a python string?

a) Deletion of Python String
b) Splitting of Python String
c) Adding elements in a Python String
d) Reassigning of Python String

View Answer Answer:- c) Adding elements in a Python String

Q2) What function do you use to read a string?

a) input(“Enter a string”)
b) eval(input(“Enter a string”))
c) enter(“Enter a string”)
d) eval(enter(“Enter a string”))

View Answer Answer:- a) input(“Enter a string”)

Q3) The format function when applied on a string returns _.

a) int
b) str
c) bool
d) Error

View Answer Answer:- b) str

Q4) What arithmetic operators cannot be used with strings?

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

View Answer Answer:- b) –

Q5) Which of the following is not a Python legal string operation?

a) ‘abc’ + ‘abc’
b) ‘abc’ * 3
c) ‘abc’ + 3
d) ‘abc’.lower()

View Answer Answer:- d) ‘abc’.lower()

Q6) To concatenate two strings to a third what statements are applicable?

a) s3 = s1 . s2
b) s3 = s1 * s2
c) s3 = s1.add(s2)
d) s3 = s1.add(s2)

View Answer Answer:- d) s3 = s1.add(s2)

Q7) 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

View Answer Answer:- c) Know Python

Q8) The output of executing string.ascii_letters can also be achieved by:

a) string.ascii_lowercase_string.digits
b) string.ascii_lowercase + string.ascii_uppercase
c) string.letters
d) string.lowercase_string.uppercase

View Answer Answer:- b) string.ascii_lowercase+string.ascii_uppercase

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

a) True
b) False

View Answer Answer:- a) True

Q10) To return the length of string s what command do we execute?

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

View Answer Answer:- a) s.len()

Also See:- String MCQ in Python– 2

Leave a Comment

Your email address will not be published. Required fields are marked *