Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer

From 166 to 180 of 820

Q. Is it possible to create a text file in python?

a. yes

b. no

c. machine dependent

d. all of the mentioned

  • a. yes

Q. What is the difference between r+ and w+ modes?

a. no difference

b. in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+

c. in w+ the pointer is initially placed at the beginning of the file and the pointer is at the end for r+

d. depends on the operating system

  • b. in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+

Q. How do you get the name of a file from a file object (fp)?

a. fp.name

b. fp.file(name)

c. self.    name    (fp)

d. fp.    name    ()

  • a. fp.name

Q. Which of the following is not a valid attribute of a file object (fp)?

a. fp.name

b. fp.closed

c. fp.mode

d. fp.size

  • d. fp.size

Q. How do you close a file object (fp)?

a. close(fp)

b. fclose(fp)

c. fp.close()

d. fp.    close    ()

  • c. fp.close()

Q. How do you get the current position within the file?

a. fp.seek()

b. fp.tell()

c. fp.loc

d. fp.pos

  • b. fp.tell()

Q. How do you rename a file?

a. fp.name = ‘new_name.txt’

b. os.rename(existing_name, new_name)

c. os.rename(fp, new_name)

d. os.set_name(existing_name, new_name)

  • b. os.rename(existing_name, new_name)

Q. How do you delete a file?

a. del(fp)

b. fp.delete()

c. os.remove(‘file’)

d. os.delete(‘file’)

  • c. os.remove(‘file’)

Q. How do you change the file position to an offset value from the start?

a. fp.seek(offset, 0)

b. fp.seek(offset, 1)

c. fp.seek(offset, 2)

d. none of the mentioned

  • a. fp.seek(offset, 0)

Q. What happens if no arguments are passed to the seek function?

a. file position is set to the start of file

b. file position is set to the end of file

c. file position remains unchanged

d. error

  • d. error

Q. Which function overloads the + operator?

a. add    ()

b. plus    ()

c. sum    ()

d. none of the mentioned

  • a.     add    ()

Q. Which function overloads the == operator?

a. eq    ()

b. equ    ()

c. isequal    ()

d. none of the mentioned

  • a.     eq    ()

Q. Which operator is overloaded by     lg    ()?

a. <

b. >

c. !=

d. none of the mentioned

  • d. none of the mentioned
Subscribe Now

Get All Updates & News