Write a python program:
using class named Example. it will accept a name, the content of the file. we will use few functions to return the name of the file, owner, set date (time it was created the file), we can also add a line and delete a line from the file. another function that returns all the data in the file. and one that deletes any previous and sets any new data user enters.
we can do like Test="a","this is the file data"
every time we make an object, we need to keep count to number the file number.
class info:
def __init__(self,file_name,content):#Constructor to initialize
data members
self.file_name=file_name
self.content=content
def set_owner(self,set_owner):# Getters and setters
self.set_owner=set_owner
def get_owner(self):
return self.set_owner
def set_content(self,content):
self.content=content
def get_content(self): # It return all the data of the file
return self.content
def get_file_name(self):
return self.file_name
f=open("Myfile.txt","w") #We have opened file in write mode.It
will create a new file if it does not exists.Whenever we open in
write mode it deletes previous data
print("Enter the data of the file :")
p=input()
f.write(p)
f.close()
f1=open("Myfile.txt","r") # we have opened the file in read mode
.
#print(f1.read())
gh=f1.read() # This would write all entered data in gh
i1=info("Myfile",gh)
i1.set_owner("mary"); #default value of owner
print("File Name: ",i1.get_file_name())
print("File Content: "+i1.get_content())
print("Owner: "+i1.get_owner())
f1.close()

Write a python program: using class named Example. it will accept a name, the content of...
Help me write a python code. Write a program that asks the user for the name of a text file, then reads each line of the text file and prints it on the screen, making every other line "title case." For example, suppose the following text is saved in my_file.txt: While I nodded, nearly napping Suddenly there came a tapping As of someone gently rapping, Rapping at my chamber door. When run, the program looks like this: Enter filename: While...
Programming Exercise 4.9
Write a script named numberlines.py. This script
creates a program listing from a source program.
This script should:
Prompt the user for the names of two files.
The input filename could be the name of the script itself, but
be careful to use a different output filename!
The script copies the lines of text from the input file to the
output file, numbering each line as it goes.
The line numbers should be right-justified in 4 columns,...
Description: Save a text document to disk based on a name and content provided by the user. Purpose: This application provides experience with user input and interaction in the Console, writing files to disk, working with exceptions, and writing programs in C#/.NET. Requirements: Project Name: Document Target Platform: Console Programming Language: C# Documentation: Types and variables (Links to an external site.) (Microsoft) Console.ReadLine Method () (Links to an external site.) (Microsoft) Strings (C# Programming Guide) (Links to an external site.)...
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
Write a program that takes a file as input and checks whether or not the content of the file is balanced. In the context of this assignment “balanced” means that your program will check to make sure that for each left bracket there is a closing right bracket. Examples: [ ( ) ] { } à balanced. [ ( ] ) { } à unbalanced. Here is the list of brackets/braces that program must support: (: left parentheses...
Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...
Ask the user for the name of a file and a word. Using the FileStats class, show how many lines the file has and how many lines contain the text. Standard Input Files in the same directory romeo-and-juliet.txt the romeo-and-juliet.txt Required Output Enter a filename\n romeo-and-juliet.txt has 5268 lines\n Enter some text\n 1137 line(s) contain "the"\n Your Program's Output Enter a filename\n romeo-and-juliet.txt has 5268 lines\n Enter some text\n 553 line(s) contain "the"\n (Your output is too short.) My...