| List-I | List-II |
| (A) f.seek(-10,1) | (I) From beginning of file, move 10 bytes forward |
| (B) f.seek(10,1) | (II) From current position, move 10 bytes backward |
| (C) f.seek(10) | (III) From current position, move 10 bytes forward |
| (D) f.seek(-10,2) | (IV) From end of the file, move 10 bytes backward |
Solution: The objective is to associate file seeking function calls with their descriptions. In Python, the seek() method, applied to a file object, modifies the file's current position. Its signature is f.seek(offset, whence), where offset specifies the byte displacement and whence indicates the reference point.
f.seek(10))f.seek(10,1) or f.seek(-10,1))f.seek(-10,2))Match the following statements to their meanings:
| (A) f.seek(-10,1) | (II) Move 10 bytes backward from the current position |
| (B) f.seek(10,1) | (III) Move 10 bytes forward from the current position |
| (C) f.seek(10) | (I) Move 10 bytes forward from the beginning of the file |
| (D) f.seek(-10,2) | (IV) Move 10 bytes backward from the end of the file |
The correct matching is as follows: (A) - (II), (B) - (III), (C) - (I), (D) - (IV)
Arrange the following in correct order of exception handling in python:
(A) Write the code that may raise an exception inside a try block
(B) Execute some code regardless of whether the exception occurs or not using the finally block
(C) Handle the specific exception using the except block
(D) Raise the exception using the raise statement if necessary
Choose the correct answer from the options given below: