COMPSCI 1MD3 Lecture Notes - Lecture 15: Newline, Standard Streams, Empty String

29 views3 pages

Document Summary

The [prompt] is optional, if it is included, it is printed to the screen. A line is read from the user and returned as a string. If the prompt is present, it is written to standard output. A line is read from standard input and returned as a string. Converts all objects with str to strings and prints them to the screen separated by sep and terminated by end print (1,2,3) or print(1,2,3,sep = "") or print(1,2,3, end = "\n\) Printing to the screen and reading from the user are modelled by special files called standard output (sys. stdout) and standard input (sys. stdin) In command-line s(cid:272)ripts, we (cid:272)an redire(cid:272)t standard input and standard output to files . Open the file for reading or writing to obtain a file handle. You can either read or write, but not both at the same time. Read or write lines to the file by referring to the file name.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions