Python Programming - Console Input/Output
Exercise : Console Input/Output - General Questions
- Console Input/Output - General Questions
6.
How can you clear the screen in a Python console application?
Answer: Option
Explanation:
You can use
os.system("clear")
to clear the screen in a Python console application.
7.
What is the purpose of the
sys.stdin
stream?
Answer: Option
Explanation:
sys.stdin
is the standard input stream in Python, used for reading input from the console.
8.
Which of the following is used to format the output?
Answer: Option
Explanation:
In Python,
f-string
is used for formatting output by embedding expressions inside string literals.
9.
How can you convert a string input from the console to an integer?
Answer: Option
Explanation:
To convert a string input to an integer in Python, you can use
int(input())
.
10.
What will happen if you try to concatenate a string and an integer using the
+
operator?
Answer: Option
Explanation:
In Python, attempting to concatenate a string and an integer using
+
will result in a TypeError.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers