Test Series - python

Test Number 29/108

Q: What will be the output of the following Python code?

print("ab	cd	ef".expandtabs())
A. ab  cd  ef
B. abcdef
C. ab cd ef
D. ab cd ef
Solution: Each 	 is converted to 8 blank spaces by default.
Q: What will be the output of the following Python code?

print("ab	cd	ef".expandtabs(4))
A. ab  cd  ef
B. abcdef
C. ab cd ef
D. ab cd ef
Solution: Each 	 is converted to 4 blank spaces.
Q: 0
A. ab+cd+ef
B. ab++++++++cd++++++++ef
C. ab cd ef
D. none of the mentioned
Solution: TypeError, an integer should be passed as an argument.
Q: What will be the output of the following Python code?

print("abcdef".find("cd") == "cd" in "abcdef")
A. True
B. False
C. Error
D. None of the mentioned
Solution: The function find() returns the position of the sunstring in the given string whereas the in keyword returns a value of Boolean type.
Q: What will be the output of the following Python code?

print("abcdef".find("cd"))
A. True
B. 2
C. 3
D. None of the mentioned
Solution: The first position in the given string at which the substring can be found is returned.
Q: What will be the output of the following Python code?

print("ccdcddcd".find("c"))
A. 4
B. 0
C. Error
D. True
Solution: The first position in the given string at which the substring can be found is returned.

You Have Score    /6