Looking for reliable answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Ask your questions and receive detailed answers from professionals with extensive experience in various fields. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
In Python:
fileName = "myfile.txt"
fname = open(fileName, "w")
fname.write("This Is File: "+str(fileName))
fname.close()
Explanation:
This initializes fileName
fileName = "myfile.txt"
This creates the file in write mode
fname = open(fileName, "w")
This writes the required string to the file
fname.write("This Is File: "+str(fileName))
This closes the file
fname.close()
The program writes a given string into a newly created file with the name of the file concatenated to the end of string written into the file. The program is written in python 3 thus ;
fileName = 'text file.txt'
#stores the name of the file into a variable.
with open(fileName, 'w') as wrtfile:
#file is opened of in the write mode and is aliased.
wrtfile.write("This is file" + str(fileName))
#writes the string into the file and add the file name the end.
Learn more :https://brainly.com/question/15086326
Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Your questions are important to us at Westonci.ca. Visit again for expert answers and reliable information.