PYTHON QUESTIONS QUESTION 6 Is it possible to have files nam
PYTHON QUESTIONS
QUESTION 6
Is it possible to have files names test.dat and TEST.DAT in the same folder/directory?
No.
Yes.
Yes, but only on Macs and Linux.
Yes, but only on Windows.
QUESTION 7
What happens if a program opens a file for writing, writes some data into it, and does not close the file before exiting?
All data written into the file is lost.
The program crashes.
Some data written into the file may be lost.
The file is automatically closed by Python.
QUESTION 8
Some file begins with the character whose charcode is 23. Is this an ASCII/Unicode text file?
No.
Not possible to tell.
Yes.
QUESTION 9
When reading from an open URL handle, rather from an open file handle, what does method .read() return?
A list of strings.
A list of numbers.
A binary object (bytes).
A string.
QUESTION 10
When reading from a URL, which functions in the following expression can crash the program?
data = urlopen(some_url).read().decode(encoding)
urlopen()
read()
decode()
Any of them.
| No. | ||
| Yes. | ||
| Yes, but only on Macs and Linux. | ||
| Yes, but only on Windows. |
Solution
The answers are :
Q6) The answer is no because we cannot write the same file name
Q7) All data written in the program is lost option 1
Q8) No, That is not ASCI
Q9) It returns a string.
Q10) decode() can crash the program

