Q. Write the file mode that will be used for opening the following files. Also, write the Python statements to open the following files:


a) a text file "example.txt" in both read and write mode

b) a binary file "bfile.dat" in write mode

c) a text file "try.txt" in append and read mode

d) a binary file "btry.dat" in read only mode.


Answer :-


a = In W+ mode example :- file = open( "example.txt", "w+" )
b = In wb mode example :- file = open("bfile.dat" , "wb" )
c = In a+ mode Example :- file = open ( "try.txt" , "a+" )
d = In rb mode Example :- file = open( "btry.dat" , "rb" )


4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. The (d) answer is
    file = open( "btry.dat" , "rb")

    ReplyDelete
  2. the (a) answer is
    file = open("exmaple.txt",r+)
    its not w+

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post