File Handling || True or False || Class 12




1. An absolute path always begins with the root folder.

2. It is not necessary to always create the file in the same default folder where Python has been installed.

3. In binary file, there is no delimiter for a line.

4. A binary file stores information in ASCII or Unicode characters.

5. readline() reads the entire file at a time.

6. A close() function breaks the link of the file object and the file on the disk.

7. When you open a file in read mode, the given file must exist in the folder, otherwise Python will raise FileNotFound error.

8. The default file open mode is write mode.

9. Opening a file in append mode erases the previous data.

10. A file mode defines the type of operations that is to be performed on the file.

11. A stream is defined as a sequence of characters.

12. readlines() function returns a list of strings, each separated by "\n".

13. file() and open() functions have different usage.

14. Data maintained inside the file is termed as "persistent” (permanent in nature) data.

15. with statement ensures that all the resources allocated to the file objects get deallocated automatically.

16. CSV module can handle CSV files correctly regardless of the operating system on which the files were created.

17. CSV module gets automatically imported into your program for reading a CSV file.

18. The type of operation that can be performed on a file depends upon the file mode in which it is opened.

19. Functions readline() and readlines() are essentially the same.

20. Every record in a CSV file is stored in reader object in the form of a list.

21. writerow() method allows us to write a list of fields to the CSV file.

22. Comma is the default delimiter for a CSV file.

23. tell() method of Python tells us the current position within the file.

24. The offset argument to seek() method indicates the number of bytes to be moved.

25. If the offset value is set to 2, beginning of the file would be taken as seek position.

26. When you open a file for reading, if the file does not exist, an error occurs.

27. When you open a file for writing, if the file does not exist, an error occurs.

28. When you open a file for writing, if the file exists, the existing file is overwritten with the new file.

29. The absolute paths are from the topmost level of the directory structure.

30. The relative paths are relative to current working directory.

31. The relative path for a file always remains same even after changing the directory.

32. The types of operations that can be carried out on a file depends upon the file mode a file is opened in.

33. If no path is given with a file name in the file open(), then the file must exist in current directory.

34. Functions readline() and readlines() are essentially the same.

35. Python automatically flushes the file buffers before closing a file with close() function.



Answers:

1. True
2. False
3. True
4. False
5. False
6. True
7. True
8. False
9. False
10. True
11. False
12. True
13. False
14. True
15. True
16. True
17. False
18. True
19. False
20. True
21. True
22. True
23. True
24. True
25. False
26. True
27. False
28. True
29. True
30. True
31. False
32. True
33. True
34. False
35. True

3 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. In the 13th Question, file() method has been mentioned but I think file() method is outdated and only open() works from Python 3. Please verify

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post