Write a function to append lines to a file do this in a


Python programming

Start a new file named defs.py

Write the code to create a function, that when called would ask the user how many lines they would like from the file. Read that many line in from bibfile.txt and print them. Test the code.

Write a new function like the above, but this time would take all of the lines and write them to a file named out.txt.

Write a function to append lines to a file. Do this in a loop that would allow the user to continue adding lines to a file until they enter the letter q.

Open a new file named testClass.py. Create a class named ask. Have this class when called print the words "Good Morning". Go back to the defs.py file and write a function that when called will instantiate a member of the ask class, you can call him fred, and then call the method to have fred print the phrase.

here is what I have so far I am stuck

i = int(input('Please enter how many lines do you want from bibfile to print: '))
f = open("bibfile.txt","r")
while i > 0:
out = f.readline()
print(out)
i = i - 1
f.close()

def print():
i = int(input('Please enter how many lines do you want from bibfile to print: '))
f = open("bibfile.txt","r")
w = open("out.txt", "w")
while i > 0:
out = f.readline()
w.write(out + "\n")
i = i - 1
f.close()
print()

def app():
i = int(input('Please enter lines you would like to append to out.txt press q to end'))
o = open("out.txt", "a")
while i in "q":

app()

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a function to append lines to a file do this in a
Reference No:- TGS02907034

Expected delivery within 24 Hours