Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
13.3k views
in Computer by (71.4k points)

Consider the following code :

f = open ("mytry", "w+")

f.write ("0123456789abcdef")

f.seek (-3,2)  //1

printf.read(2)  //2

Explain statement 1 and give output of 2.

1 Answer

+1 vote
by (76.5k points)
selected by
 
Best answer

Statement 1 uses seek()method can be used to position the file object at particular place in the file. It's syntax is: fileobject.seek(offset [, from_what]).

So,f.seek(-3,2) positions the fileobject to 3 bytes before end of file.

Output of 2 is: de (It reads 2 bytes from where the file object is placed.)

No related questions found

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...