UPDATED ACTUAL Exam Questions and
CORRECT Answers
Python's built-in function named open () tries to open a file and returns:
A. an integer value identifying an opened file
B. an error code (0 means success)
C. a stream object
D. always None - CORRECT ANSWER A. an integer value identifying an opened file
What can you deduce from the following statement0 (Select two answers) str = open('file.txt',
"rt")
A. str is a string read in from the file named file. txt
B. a newlina character translation will be performed during the reads
C. if file. txt does not exist, it will be created
D. the opened file cannot be written with the use of the str variable - CORRECT
ANSWER A. str is a string read in from the file named file. txt
D. the opened file cannot be written with the use of the str variable
You are going to read just one character from a stream called s. Which statement would you use?
A. ch = read(s, 1)
B. ch = s. input(1)
C. ch = input(s, 1)
D. ch = s. read(l) - CORRECT ANSWER D. ch = s. read(l)
There is a stream named s open for writing. What option will vou select to write a line to the
stream''
A. s.write("Hello\n")
B. write(s, "Hello")