Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. >>>print("A", end = ' ')
a. dcba
b. a, b, c, d
c. d c b a
d. d, c, b, a will be displayed on four lines
Q. To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?
a. s[]
b. s.getitem(3)
c. s. getitem (3)
d. s.getitem(3)
Q. To return the length of string s what command do we execute?
a. s. len ()
b. len(s)
c. size(s)
d. s.size()
Q. If a class defines the str (self) method, for an object obj for the class, you can use which command to invoke the str method.
a. obj. str ()
b. str(obj)
c. print obj
d. all of the mentioned
Q. 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)
Q. 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”))