Console Input/Output Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q1
Which function is used to read input from the console in Python?
  • A scanf()
  • B read()
  • C input()
  • D get()
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?
  • A The printed string
  • B 0
  • C None
  • D True
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?
  • A Using + operator
  • B Using commas
  • C Using & operator
  • D Using concat()
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?
  • A Integer
  • B Float
  • C String
  • D Boolean
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?
  • A newline
  • B sep
  • C end
  • D break
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?
  • A str_to_int()
  • B integer()
  • C int()
  • D convert_int()
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="-")?
  • A Hello World
  • B Hello-World
  • C Hello,World
  • D Hello - World
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?
  • A printf()
  • B format()
  • C formatted()
  • D output()
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()?
  • A Returns None
  • B Returns 0
  • C Returns empty string
  • D Raises an error
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?
  • A Using concatenation with +
  • B Using multiple print statements
  • C Using f-strings
  • D All of the above
Answer: Option D
Explanation: Using f-strings or format() method allows you to embed variables within descriptive text for clear output.
Questions and Answers for Competitive Exams Various Entrance Test