gs gs109 Python Files - Python Files - Quiz No.1
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 1: To open a file c:\scores.txt for reading, we use _____________
infile = open(“c:\scores.txt”, “r”)
infile = open(“c:\\scores.txt”, “r”)
infile = open(file = “c:\scores.txt”, “r”)
infile = open(file = “c:\\scores.txt”, “r”)
Question 2: To open a file c:\scores.txt for writing, we use ____________
outfile = open(“c:\scores.txt”, “w”)
outfile = open(“c:\\scores.txt”, “w”)
outfile = open(file = “c:\scores.txt”, “w”)
outfile = open(file = “c:\\scores.txt”, “w”)
Question 3: To open a file c:\scores.txt for appending data, we use ____________
outfile = open(“c:\\scores.txt”, “a”)
outfile = open(“c:\\scores.txt”, “rw”)
outfile = open(file = “c:\scores.txt”, “w”)
outfile = open(file = “c:\\scores.txt”, “w”)
Question 4: Which of the following statements are true?
When you open a file for reading, if the file does not exist, an error occurs
When you open a file for writing, if the file does not exist, a new file is created
When you open a file for writing, if the file exists, the existing file is overwritten with the new file
All of the mentioned
Question 5: To read two characters from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Question 6: To read the entire remaining contents of the file as a string from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Question 8: To read the next line of the file from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Question 9: To read the remaining lines of the file from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
Question 10: The readlines() method returns ____________
str
a list of lines
a list of single characters
a list of integers