CISC 121 Lecture Notes - Lecture 9: Newline

194 views3 pages
Verified Note

Document Summary

Python functions can return 1+ value, in a sense. What the calling statement gets back is a tuple . Some of what we"ll cover in this course may involve work with text data files stored on disk, so let"s look at disk file i/o. def spam(a, b): return b, a my_tuple = spam(3,4) print(my_tuple) The example makes an empty text file in the current folder, the folder that contains the program that creates the file. Test. txt, without the quotes, is the name of the file, and the. W" is short for write. if a file of the same name already exists in the current folder, it will be overwritten. Once this statement is executed, the file will be ready for data, and we refer to the file form this point on using my_file. Now we can write some lines of text to the file.

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