1.

What is the use of truncate() method in file?(a) truncates the file size(b) deletes the content of the file(c) deletes the file size(d) none of the mentionedThis question was addressed to me by my school teacher while I was bunking the class.Question is from Files topic in chapter Regular Expressions and Files of Python

Answer»

The CORRECT answer is (a) truncates the FILE SIZE

The best EXPLANATION: The method TRUNCATE() truncates the file size. Following is the syntax for truncate() method:

fileObject.truncate( [ size ])

Parameters

size — If this optional argument is present, the file is truncated to (at most) that size.



Discussion

No Comment Found

Related InterviewSolutions