Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which method reads the next line in a file?

View

What does the write() method return?

View

How do you write binary data to a file?

View

Which statement is correct for reading a file line by line?

View

What will happen if you open an existing file in 'w' mode?

View

What does the tell() function return?

View

Which method moves the file pointer to a specific location?

View

Which exception is raised for file-related errors?

View

Which of the following modes will create a file if it doesn’t exist?

View

How do you check if a file is closed?

View

Which method reads the next line in a file?

readline()
read()
nextline()
line()

What does the write() method return?

The file object
None
The number of characters written
Boolean indicating success

How do you write binary data to a file?

Open file in ‘wb’ mode
Use text mode with binary input
Convert binary to string first
Use json.dump()

Which statement is correct for reading a file line by line?

for line in file:
file.read_line()
while line = file.readline():
file.line()

What will happen if you open an existing file in 'w' mode?

File will be deleted
File will be truncated to zero size
An error will be raised
A new file will be created

What does the tell() function return?

Size of the file
Current position of the file pointer
Encoding type of the file
None of the above

Which method moves the file pointer to a specific location?

seek()
move()
locate()
rewind()

Which exception is raised for file-related errors?

ValueError
FileNotFoundError
FileError
IOError

Which of the following modes will create a file if it doesn’t exist?

'x'
'r'
'a'
'rb'

How do you check if a file is closed?

file.is_closed()
file.close() == False
file.closed
file.closable()