Answer
For opening a file for reading we use open(filePath, "r")
For opening a file for writing we use open(filePath, "w")
For opening a file for appending we use open(filePath, "a")
Work Step by Step
For opening a file we use open function in python, it take two parameters, the first one denotes the filepath and the second decides the mode. We pass following strings to mode argument for different purposes.
"r" to open a file for reading,
"w" to open a file for writing,
"a" to open a file for appending.