On This Page

This set of Problem Solving and Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Problem Solving And Python Programming Set 5

Q1 | )
  • 0 1 2 0
  • 0 1 2
  • error
  • none of the mentioned
Q2 | )
  • 0 1 2 3 0
  • 0 1 2 0
  • 0 1 2
  • error
Q3 | ): print(i)
  • 0
  • no output
  • error
  • none of the mentioned
Q4 | 0): print(i)
  • 0.0 1.0
  • 0 1
  • error
  • none of the mentioned
Q5 | 0)): print(i)
  • 0.0 1.0
  • 0 1
  • error
  • none of the mentioned
Q6 | ])
  • 0 1 2 3
  • 0 1 2 2
  • 3 3 3 3
  • error
Q7 | ] in a: print(a[0])
  • 0 1 2 3
  • 0 1 2 2
  • 3 3 3 3
  • error
Q8 | >>>"a"+"bc
  • a
  • bc
  • bca
  • abc
Q9 | >>>"abcd"[2:]
  • a
  • ab
  • cd
  • dc
Q10 | >>> str1[-1:]
  • olleh
  • hello
  • h
  • o
Q11 | What arithmetic operators cannot be used with strings?
  • +
  • *
  • all of the mentioned
Q12 | >>>print (r"\nhello")
  • a new line and hello
  • \\nhello
  • the letter r and then hello
  • error
Q13 | >>>print('new' 'line')
  • error
  • output equivalent to print ‘new\\nline’
  • newline
  • new line
Q14 | >>>str1[::-1]
  • dlrowolleh
  • hello
  • world
  • helloworld
Q15 | xA + 0xB + 0xC)
  • 0xa0xb0xc
  • error
  • 0x22
  • 33
Q16 | >>>print "%d %d" % (obj.o1, obj.o2)
  • none none
  • none 22
  • 22 none
  • error is generated
Q17 | >>>print(temp.id)
  • 224
  • error
  • 12
  • none
Q18 | >>>print("%s" % example[4:7])
  • wo
  • world
  • sn
  • rl
Q19 | >>>print example
  • snow
  • snow world
  • error
  • snos world
Q20 | >>>max("what are you")
  • error
  • u
  • t
  • y
Q21 | Given a string example=”hello” what is the output of example.count(‘l’)?
  • 2
  • 1
  • none
Q22 | >>>example.find("e")
  • error
  • -1
  • 1
Q23 | >>>example.rfind("e")
  • -1
  • 4
  • 3
  • 1
Q24 | >>>example[::-1].startswith("d")
  • dlrowolleh
  • true
  • -1
  • none
Q25 | To concatenate two strings to a third what statements are applicable?
  • s3 = s1 . s2
  • s3 = s1.add(s2)
  • s3 = s1.    add    (s2)
  • s3 = s1 * s2