Problem Solving And Python Programming Set 24
On This Page
This set of Problem Solving and Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Problem Solving And Python Programming Set 24
Q1 | 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
Q2 | >>>chr(ord('A'))
- a
- b
- a
- error
Q3 | >>>print(chr(ord('b')+1))
- a
- b
- c
- a
Q4 | Which of the following statement prints hello\example\test.txt?
- print(“hello\\example\\test.txt”)
- print(“hello\\example\\test.txt”)
- print(“hello\\”example\\”test.txt”)
- print(“hello”\\example”\\test.txt”)
Q5 | Suppose s is “\t\tWorld\n”, what is s.strip()?
- \\t\\tworld\\n
- \\t\\tworld\\n
- \\t\\tworld\\n
- world
Q6 | The format function, when applied on a string returns
- error
- int
- bool
- str
Q7 | +2+3?
- hello123
- hello
- error
- hello6
Q8 | >>>print("A", end = ' ')
- dcba
- a, b, c, d
- d c b a
- d, c, b, a will be displayed on four lines
Q9 | What will be displayed by print(ord(‘b’) – ord(‘a’))?
- 0
- 1
- -1
- 2
Q10 | Say s=”hello” what will be the return value of type(s)?
- int
- bool
- str
- string
Q11 | What is “Hello”.replace(“l”, “e”)?
- heeeo
- heelo
- heleo
- none
Q12 | To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed)?
- s[]
- s.getitem(3)
- s. getitem (3)
- s.getitem(3)
Q13 | To return the length of string s what command do we execute?
- s. len ()
- len(s)
- size(s)
- s.size()
Q14 | 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.
- obj. str ()
- str(obj)
- print obj
- all of the mentioned
Q15 | To check whether string s1 contains another string s2, use
- s1. contains (s2)
- s2 in s1
- s1.contains(s2)
- si.in(s2)
Q16 | Suppose i is 5 and j is 4, i + j is same as
- i. add(j)
- i. add (j)
- i. add(j)
- i. add(j)
Q17 | print(id(s1) == id(s2))
- true false
- true true
- false true
- false false
Q18 | What function do you use to read a string?
- input(“enter a string”)
- eval(input(“enter a string”))
- enter(“enter a string”)
- eval(enter(“enter a string”))
Q19 | ))
- cd
- abcdef
- error
- none of the mentioned
Q20 | ), '*')
- * abcdef *
- * abcdef *
- *abcdef *
- * abcdef*
Q21 | ), '*', sep= '')
- * abcdef *
- * abcdef *
- *abcdef *
- * abcdef*
Q22 | , 1))
- 1abcdef
- abcdef1
- abcdef
- error
Q23 | , '1'))
- 1abcdef
- abcdef1
- abcdef
- error
Q24 | , '12'))
- 12abcdef12
- abcdef1212
- 1212abcdef
- error
Q25 | ))
- 2
- 0
- 1
- none of the mentioned