Console Input/Output Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
How to format a number to 2 decimal places in output?
Answer: Option D
Explanation: f-strings or format() method with formatting specifications can control decimal places in output.
Q22
What is the difference between print and return?
Answer: Option B
Explanation: print displays output to console, while return sends a value back from a function to the caller.
Q23
How to read password input without displaying it?
Answer: Option B
Explanation: The getpass module provides getpass() function that reads input without echoing it to the screen.
Q24
What does the file parameter in print() do?
Answer: Option B
Explanation: The file parameter redirects output to a file-like object instead of standard output (console).
Q25
How to display a backslash character in string?
Answer: Option B
Explanation: Backslash is escape character, so to display it, use double backslash \\.