270). What will be the output of the following Python code?
print("ab\tcd\tef".expandtabs())
[A]ab cd ef
[B]abcdef
[C]ab\tcd\tef
[D]ab cd ef
Show Answer
Correct Answer: ab cd ef
Notes:
Answer: a
Explanation: Each \t is converted to 8 blank spaces by default.
271). What will be the output of the following Python code?
print("ab\tcd\tef".expandtabs(4))
[A]ab cd ef
[B]abcdef
[C]ab\tcd\tef
[D]ab cd ef
Show Answer
Correct Answer: ab cd ef
Notes:
Answer: d
Explanation: Each \t is converted to 4 blank spaces.
272). What will be the output of the following Python code?
print("ab\tcd\tef".expandtabs('+'))
[A]ab+cd+ef
[B]ab++++++++cd++++++++ef
[C]ab cd ef
[D]none of the mentioned
Show Answer
Correct Answer: none of the mentioned
Notes:
Answer: d
Explanation: TypeError, an integer should be passed as an argument.
273). 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
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: The function find() returns the position of the sunstring in the given string whereas the in keyword returns a value of Boolean type.
274). 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
Show Answer
Correct Answer: 2
Notes:
Answer: b
Explanation: The first position in the given string at which the substring can be found is returned.
275). What will be the output of the following Python code?
print("ccdcddcd".find("c"))
[A]4
[B]0
[C]Error
[D]True
Show Answer
Correct Answer: 0
Notes:
Answer: b
Explanation: The first position in the given string at which the substring can be found is returned.
276). What will be the output of the following Python code?
print("Hello {0} and {1}".format('foo', 'bin'))
[A]Hello foo and bin
[B]Hello {0} and {1} foo bin
[C]Error
[D]Hello 0 and 1
Show Answer
Correct Answer: Hello foo and bin
Notes:
Answer: a
Explanation: The numbers 0 and 1 represent the position at which the strings are present.
277). What will be the output of the following Python code?
print("Hello {1} and {0}".format('bin', 'foo'))
[A]Hello foo and bin
[B]Hello bin and foo
[C]Error
[D]None of the mentioned
Show Answer
Correct Answer: Hello foo and bin
Notes:
Answer: a
Explanation: The numbers 0 and 1 represent the position at which the strings are present.
278). What will be the output of the following Python code?
print("Hello {} and {}".format('foo', 'bin'))
[A]Hello foo and bin
[B]Hello {} and {}
[C]Error
[D]Hello and
Show Answer
Correct Answer: Hello foo and bin
Notes:
Answer: a
Explanation: It is the same as Hello {0} and {1}.
279). What will be the output of the following Python code?
print("Hello {name1} and {name2}".format('foo', 'bin'))
[A]Hello foo and bin
[B]Hello {name1} and {name2}
[C]Error
[D]Hello and
Show Answer
Correct Answer: Error
Notes:
Answer: c
Explanation: The arguments passed to the function format aren’t keyword arguments.