Python Programming - Console Input/Output

Exercise : Console Input/Output - General Questions
  • Console Input/Output - General Questions
1.
How can you take user input from the console?
console.input()
input()
read.console()
console.read_input()
Answer: Option
Explanation:
The input() function is used to take user input from the console in Python. It reads a line from the console and returns it as a string.

2.
Which function is used to print output to the console?
display()
show()
print()
console.log()
Answer: Option
Explanation:
The print() function is used to display output on the console in Python. It can be used to print variables, strings, and expressions.

3.
How can you read an integer input from the console?
int_input()
read_integer()
int(input())
read.console(integer)
Answer: Option
Explanation:
To read an integer input from the console, you can use int(input()) to convert the input string to an integer.

4.
What will happen if you try to use input() without assigning it to a variable?
Error: input() cannot be used without assignment
The input will be ignored
The program will terminate
The input will be printed to the console
Answer: Option
Explanation:
If you use input() without assigning it to a variable, the entered input will be displayed on the console.

5.
How can you prompt the user with a message while taking input?
prompt(input_msg)
input_msg(prompt)
input(prompt=input_msg)
console.prompt(input_msg)
Answer: Option
Explanation:
You can use the input() function with the optional parameter prompt to display a message to the user before taking input.