Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

Differentiate between w and w+ file modes in Python. What happens if the file does not exist in each mode?

Answer:

Answer by student

The w mode is used to open a file for writing only . It will overwrite the existing file if it exists, or create a new file if it does not exist.

The w+ mode is used to open a file for both writing and reading . It will also overwrite the existing file if it exists, or create a new file if it does not exist.

Detailed answer by teachoo

The rest of the post is locked. Join Teachoo Black to see the full post.

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo