PCAP 31 03 PCAP Certified Associate Python Programmer · Free Practice Question Easy
Question 26
Q471 - Modules
The sys.stderr stream is normally associated with:
-
A
the screen
-
B
the printer
-
C
the keyboard
-
D
a null device
Reveal correct answer
Correct answer: A
Explanation
Topic: sys.stderr
Try it yourself:
- import sys
- print('Error 1', file=sys.stderr) # Error 1
- sys.stderr.write('Error 2') # Error 2
Explanation:
Here are two different ways to send a string to the sys.stderr stream.
You will see both messages on the screen,
because the sys.stderr stream is normally associated with the screen.
Q471 (Please refer to this number, if you want to write me about this question.)
A. The sys.stderr stream is typically associated with the screen, where error messages and output are displayed to the user. It is commonly used for displaying error messages and exceptions during program execution.
B. The sys.stderr stream is not normally associated with the printer. It is primarily used for displaying error messages and output on the screen rather than sending them to a physical printer device.
C. The sys.stderr stream is not normally associated with the keyboard. It is used for displaying error messages and output on the screen, not for receiving input from the keyboard.
D. The sys.stderr stream is not typically associated with a null device. A null device is used to discard output and is not typically used for displaying error messages or output to the user.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
