Write a statement to write the string “Welcome! Please have a seat” in a file wel.txt, that has not yet been opened.



f1 = open ("wel.txt", 'w') 

f1.write ("Welcome! Please have a seat") 


  • f1 is the file object.
  • open( ) method opens the file for writing to it.
  • “wel.text” is the file name.
  • ‘w’ is the access mode ie., the file is opened to write to it. 
  • write( ) method writes the specified string to the file.

Learn in your speed, with individual attention - Teachoo Maths 1-on-1 Class

Ask a doubt
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 13 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.