Console Input/Output Questions and Answers
Practice ModeShowing 10 of 25 questions
Q1
Which function is used to read input from the console in Python?
Answer: Option C
Explanation: The input() function is used to read input from the console as a string.
Q2
What does the print() function return in Python?
Answer: Option C
Explanation: The print() function returns None in Python. It outputs text to the console but doesn't return any meaningful value.
Q3
How can you display multiple values in a single print statement?
Answer: Option B
Explanation: Multiple values can be separated by commas in the print() function, and they will be separated by spaces in the output.
Q4
What is the default data type of input received from input() function?
Answer: Option C
Explanation: The input() function always returns the user input as a string, regardless of what is entered.
Q5
Which parameter in print() function prevents newline at the end?
Answer: Option C
Explanation: The end parameter in print() controls what is printed at the end. Default is \n, but it can be changed to empty string or other characters.
Q6
How to convert string input to integer in Python?
Answer: Option C
Explanation: The int() function converts a string to an integer. It's necessary when you need numerical input.
Q7
What is the output of: print("Hello", "World", sep="-")?
Answer: Option B
Explanation: The sep parameter specifies the separator between multiple values in print(). Default is space, but here it's set to hyphen.
Q8
Which function is used for formatted output in Python?
Answer: Option B
Explanation: The format() method or f-strings (in Python 3.6+) are used for formatted output, providing more control over how values are displayed.
Q9
What happens if you press Enter without typing anything in input()?
Answer: Option C
Explanation: When you press Enter without typing anything, input() returns an empty string ("").
Q10
How to display a variable value with descriptive text?
Answer: Option D
Explanation: Using f-strings or format() method allows you to embed variables within descriptive text for clear output.