Test Series - python

Test Number 25/108

Q: Which of the following statement prints helloexample	est.txt?
A. print(“helloexample est.txt”)
B. print(“hello\example\test.txt”)
C. print(“hello”example”test.txt”)
D. print(“hello”example” est.txt”)
Solution: is used to indicate that the next  is not an escape sequence.
Q: Suppose s is “		World
”, what is s.strip()?
A.  World
B.  World
C.  WORLD
D. World
Solution: Execute help(string.strip) to find details.
Q: The format function, when applied on a string returns ___________
A. Error
B. int
C. bool
D. str
Solution: Format function returns a string.
Q: What will be the output of the “hello” +1+2+3?
A. hello123
B. hello
C. Error
D. hello6
Solution: Cannot concatenate str and int objects.
Q: What will be the output of the following Python code?

>>>print("D", end = )
>>>print("C", end = )
>>>print("B", end = )
>>>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
Solution: Execute in the shell.
Q: What will be displayed by print(ord(‘b’) – ord(‘a’))?
A. 0
B. 1
C. -1
D. 2
Solution: ASCII value of b is one more than a. Hence the output of this code is 98-97, which is equal to 1.
Q: Say s=”hello” what will be the return value of type(s)?
A. int
B. bool
C. str
D. String
Solution: str is used to represent strings in python.

You Have Score    /7