Python Programming - Console Input/Output
Exercise : Console Input/Output - General Questions
- Console Input/Output - General Questions
21.
What will the
end
parameter in the print()
function do?
Answer: Option
Explanation:
The
end
parameter in print()
sets the end character that will be printed at the end of the string.
22.
How can you remove leading and trailing whitespaces from a string?
Answer: Option
Explanation:
The
strip()
method in Python is used to remove leading and trailing whitespaces from a string.
23.
How can you check if a string ends with a specific suffix?
Answer: Option
Explanation:
To check if a string ends with a specific suffix in Python, you can use the
endswith()
method.
24.
How can you print a formatted string with variable values?
Answer: Option
Explanation:
Using a comma in the
print()
function allows you to print a formatted string with variable values in Python.
25.
How can you read a boolean value from the console?
Answer: Option
Explanation:
To read a boolean value from the console in Python, you can compare the input (converted to lowercase) with the string 'true'.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers