Skip to main content

Posts

Showing posts from April, 2018

Pyhton Programming

Programs to Read and Write Files #program to read files f=open("abc.txt",'r') f.read() f.close #program for writing files f=open("abc.txt",'w') f.write("HEllO WOrld") f.close #programs based on read and write files a=open("text.txt","w") a.write(“welcome to python”) a.write(“This my first line\n”) a.write(“This is my second line\n”) a.write(“This is third line\n”) a.close() #Program to write lines of text  Obj=open(“text.txt”,”w”) Lot=[“Python is the software “,”\n which is used for create and run the program “,”\n Python programming language”] Obj.writelines(Lot) Obj.close()  #Create a program to first check to see if the file name is exist .So if it will give an error massage if it will not create the file  import os def create_file()         if os.path.isfile(“text.txt”):              print(“file already exists”...