MCQ on String in Python – 3

Q1) What is the output of the given below program?

string = "5/3"
print("string")

a) 5/3
b) string
c) Error
d) None of these

View Answer Answer:- b) string

Q2) Find the output of the given Python program?

string = "Know Program "
print(string*2)

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

View Answer Answer:- b) Know Program Know Program

Q3) What is the output of the given below program?

string = "Know Program"
string.upper()
print(string)

a) Know Program
b) kNOW pROGRAM
c) KNOW PROGRAM
d) Error

View Answer Answer:- a) Know Program

Q4) What is the output of the given below program?

string1 = "Know Program"
string2 = string1.replace('o', 'O')
print(string2)

a) KnOw Program
b) Know PrOgram
c) KnOw PrOgram
d) Error

View Answer Answer:- c) KnOw PrOgram

Q5) Find the output of the given Python program?

string1 = str("Know Program")
string2 = "Know Program"
print(string1 == string2)

a) True
b) False

View Answer Answer:- a) True

Q6) What is the output of the given below program?

string1 = "Know"
string2 = "Program"
print(string1 < string2)

a) True
b) False

View Answer Answer:- a) True

Q7) Find the output of the given Python program?

s = "Know Program"
print(s[3] * s.index("P"))

a) PPP
b) wwwww
c) wP
d) Error

View Answer Answer:- b) wwwww

Q8) Find the output of the given Python program?

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

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

View Answer Answer:- b) 2

Q9) What is the output of the given below program?

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

a) 5
b) 6
c) Error
d) None of these

View Answer Answer:- a) 5

Q10) Find the output of the given Python program?

print("Pr" in "Know Program" == "Know Program".find("Pr"))

a) True
b) False
c) Error

View Answer Answer:- b) False

Q11) Find the output of the given Python program?

print('Know '.partition('Program'))

a) (‘Know’)
b) (‘Know’,”,”)
c) (‘Know Program’)
d) (‘Know’, ‘Program’)

View Answer Answer:- b) (‘Know’,”,”)

Also See:- Tuple MCQ in Python

Leave a Comment

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