229). What will be the output of the following Python statement?
>>>chr(ord('A'))
Show Answer
Correct Answer: A
Notes:
Answer: a
Explanation: Execute in shell to verify.
230). What will be the output of the following Python statement?
>>>print(chr(ord('b')+1))
Show Answer
Correct Answer: c
Notes:
Answer: c
Explanation: Execute in the shell to verify.
231). Which of the following statement prints hello\example\test.txt?
>>>print(chr(ord('b')+1))
[A]print(“hello\example\test.txt”)
[B]print(“hello\\example\\test.txt”)
[C]print(“hello\”example\”test.txt”)
[D]print(“hello”\example”\test.txt”)
Show Answer
Correct Answer: print(“hello\\example\\test.txt”)
Notes:
Answer: b
Explanation: \is used to indicate that the next \ is not an escape sequence.
232). Suppose s is “\t\tWorld\n”, what is s.strip()?
>>>print(chr(ord('b')+1))
[A]\t\tWorld\n
[B]\t\tWorld\n
[C]\t\tWORLD\n
[D]World
Show Answer
Correct Answer: World
Notes:
Answer: d
Explanation: Execute help(string.strip) to find details.
233). The format function, when applied on a string returns ___________
>>>print(chr(ord('b')+1))
[A]Error
[B]int
[C]bool
[D]str
Show Answer
Correct Answer: str
Notes:
Answer: d
Explanation: Format function returns a string.
234). What will be the output of the “hello” +1+2+3?
>>>print(chr(ord('b')+1))
[A]hello123
[B]hello
[C]Error
[D]hello6
Show Answer
Correct Answer: Error
Notes:
Answer: c
Explanation: Cannot concatenate str and int objects.
235). 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
Show Answer
Correct Answer: D C B A
Notes:
Answer: c
Explanation: Execute in the shell.
236). What will be the output of the following Python statement?(python 3.xx)
>>>print(format("Welcome", "10s"), end = '#')
>>>print(format(111, "4d"), end = '#')
>>>print(format(924.656, "3.2f"))
[A]Welcome# 111#924.66
[B]Welcome#111#924.66
[C]Welcome#111#.66
[D]Welcome # 111#924.66
Show Answer
Correct Answer: Welcome # 111#924.66
Notes:
Answer: d
Explanation: Execute in the shell to verify.
237). What will be displayed by print(ord(‘b’) – ord(‘a’))?
>>>print(format("Welcome", "10s"), end = '#')
>>>print(format(111, "4d"), end = '#')
>>>print(format(924.656, "3.2f"))
Show Answer
Correct Answer: 1
Notes:
Answer: b
Explanation: ASCII value of b is one more than a. Hence the output of this code is 98-97, which is equal to 1.
238). Say s=”hello” what will be the return value of type(s)?
>>>print(format("Welcome", "10s"), end = '#')
>>>print(format(111, "4d"), end = '#')
>>>print(format(924.656, "3.2f"))
[A]int
[B]bool
[C]str
[D]String
Show Answer
Correct Answer: str
Notes:
Answer: c
Explanation: str is used to represent strings in python.