Suppose a file named test.txt has content 1 2 3 4 5 6 7 in it.Now what will be the output of the following code :-
file = open("test.txt",'r')
file.read(5)
Answers
Answered by
0
Given: File named test.txt has content 1 2 3 4 5 6 7.
To find: What will be the output of the code?
Solution:
- The code is:
file = open("test.txt",'r')
file.read(5)
- In the first line of code, the command is given to open the file and r is the mode to read the file.
- In second line of the code, we have given the command .read and 5 is passed to it, that means only first 5 characters of file will be printed to read it.
- So the output will be: 1 2 3
space is also included in it.
Answer:
So the output will be 1 2 3.
Similar questions