Console Input/Output Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
What is the purpose of the prompt message in input()?
Answer: Option B
Explanation: The prompt message in input() is displayed to the user to indicate what kind of input is expected.
Q12
Which escape sequence adds a tab space in print()?
Answer: Option B
Explanation: Escape sequences start with backslash. \t adds a tab space, \n adds newline, \\ adds backslash itself.
Q13
How to read multiple inputs in a single line?
Answer: Option B
Explanation: split() method can be used with input() to read multiple values separated by spaces in one line.
Q14
What does the flush parameter in print() do?
Answer: Option B
Explanation: The flush parameter forces the output to be written immediately instead of buffering. Default is False.
Q15
Which method is used to convert input to floating-point number?
Answer: Option B
Explanation: float() function converts strings to floating-point numbers, useful for decimal input.
Q16
How to display special characters like quotes in strings?
Answer: Option D
Explanation: Escape sequences with backslash or using different quote types allows displaying special characters.
Q17
What is the output of: print(10, 20, 30, sep="::")?
Answer: Option B
Explanation: The sep parameter replaces the default space separator with the specified string between values.
Q18
How to handle EOFError in input()?
Answer: Option B
Explanation: EOFError occurs when input() reaches end-of-file. It can be handled using try-except block.
Q19
Which function was used for console input in Python 2?
Answer: Option B
Explanation: In Python 2, raw_input() was used for string input and input() evaluated the input as Python expression.
Q20
What is the output of: print("A", "B", "C", end="!")?
Answer: Option B
Explanation: The end parameter replaces the default newline with the specified string at the end of output.