gs gs109 Python Files - Python Files - Quiz No.5
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python Files. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 2: What is the difference between r+ and w+ modes?
no difference
in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+
in w+ the pointer is initially placed at the beginning of the file and the pointer is at the end for r+
depends on the operating system
Question 3: How do you get the name of a file from a file object (fp)?
fp.name
fp.file(name)
self.__name__(fp)
fp.__name__()
Question 4: Which of the following is not a valid attribute of a file object (fp)?
fp.name
fp.closed
fp.mode
fp.size
Question 5: How do you close a file object (fp)?
close(fp)
fclose(fp)
fp.close()
fp.__close__()
Question 6: How do you get the current position within the file?
fp.seek()
fp.tell()
fp.loc
fp.pos
Question 7: How do you rename a file?
fp.name = ‘new_name.txt’
os.rename(existing_name, new_name)
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
Question 8: How do you delete a file?
del(fp)
fp.delete()
os.remove(‘file’)
os.delete(‘file’)
Question 9: How do you change the file position to an offset value from the start?
fp.seek(offset, 0)
fp.seek(offset, 1)
fp.seek(offset, 2)
none of the mentioned
Question 10: What happens if no arguments are passed to the seek function?
file position is set to the start of file
file position is set to the end of file
file position remains unchanged
error