Python Input and Output
Python Input and Output - Important Points
21. | Which of the following is used to write data to a file in Python? |
---|
A. write()
B. read()
C. close()
D. D. open()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The write() method is used to write data to a file in Python.
22. | Which of the following modes is used to read a file in Python? |
---|
A. 'w'
B. 'r'
C. 'a'
D. 'x'
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The 'r' mode is used to read a file in Python.
23. | Which of the following modes is used to write to a file in Python? |
---|
A. 'r'
B. 'w'
C. 'a'
D. 'x'
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The 'w' mode is used to write to a file in Python.
24. | Which of the following modes is used to append data to a file in Python? |
---|
A. 'r'
B. 'w'
C. 'a'
D. 'x'
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The 'a' mode is used to append data to a file in Python.
25. | Which of the following is used to close a file in Python? |
---|
A. close()
B. write()
C. read()
D. D. open()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The close() method is used to close a file in Python.