CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

STANDARD INPUT ,OUTPUT AND ERROR STREAMS

Standard Streams: stdin, stdout, stderr:

Standard Streams:

  • stdin: Standard Input Device (Ex. Reading from Keyboa
  • Stdout: Standard Output Device (Ex. Printing on Monitor)
  • Stderr: Same as stdout but normally only for errors.

Internally these standard devices are implemented as files called
Standard Streams. These are available in sys Module.

After importing sys Module we can use these Standard Streams in
the same way you use other files.


import sys

  • sys.stdin.read() – let you read from keyboard
  • sys.stdout.write() – let you write of the standard output Device
  • sys.stderr.write() – let you write the error

When we start python these files opened in:
  • stdin(read mode)
  • stout(write mode)
  • stderr(write mode)

Sample Program - 1

Sample Program - 2





No comments:

Post a Comment