- What is the output of the following code?
f = None for i in range (5): with open("data.txt", "w") as f: if i > 2: break print(f.closed) a) True b) False c) None d) Error
- To open a file c:\books.txt for reading, we use:
a) infile = open("c:\books.txt", "r") b) infile = open("c:\\books.txt", "r") c) infile = open(file = "c:\books.txt", "r") d) infile = open(file = "c:\\books.txt", "r")
- Write a statement in Python to perform the following operations :
- To open a text file “BOOK.TXT” in read mode
- To open a text file “BOOK.TXT” in write mode
- Which of the following File Modes creates a new file, if the file does not exist? (choose one/more)
- 'r'
- 'bw'
- 'w'
- 'a'
- In which of the following mode the existing data of the file will not be lost?(choose one/more)
- 'rb'
- 'wb'
- 'w+'
- 'r+'
- In which of the following file modes the existing data of the file will not be lost?
rb, ab, w, w+b, a+b, wb, wb+, w+, r+ - What will the output of the following code :
1 2 3
f1 = open("test1.txt","r") size = len(f1.read()) print(f1.read(5))
- Differentiate between r+ and w+ with respect to Python file handling.
very helpful.thanks for your supportive upload
ReplyDelete