Question: Files. Read the following code and answer the next five questions about it. The contents of the files list1.txt and list2.txt are the following (given

 Files. Read the following code and answer the next five questions
about it. The contents of the files list1.txt and list2.txt are the
following (given side by side): list1.txt content: list2.txt content: 2 apples 3
oranges 2 apples 1 loaf of bread 2 eggs 2 eggs 1
cereal box # the program code starts here filenamel - "listi.txt" filename2
- "list2.txt" filename 3 "listdiff.txt" with open (filename1, "r") as fi, open

Files. Read the following code and answer the next five questions about it. The contents of the files list1.txt and list2.txt are the following (given side by side): list1.txt content: list2.txt content: 2 apples 3 oranges 2 apples 1 loaf of bread 2 eggs 2 eggs 1 cereal box # the program code starts here filenamel - "listi.txt" filename2 - "list2.txt" filename 3 "listdiff.txt" with open (filename1, "r") as fi, open (filename2, "r") as f2, open (filename3, "w") as f3 : for line in f1: if line.stripo f2.readline().stripo: print (line, end = "") else: f3.write(line) Problem 3 Q1. How many lines are printed to the standard output? O 4. 07 O2 O 3 5 O 1 6 Problem 3 Q2. How many lines are printed to the listdiff.txt file? O 5 O 1 6 0 3 O2 4 0 7 Problem 3 Q3. The code does not have a try-except statement. So, if a file referred by the variable filename3 does not exist, will running the code generate an error? Assume that the code does not generate an error if the file exists. Yes O No Problem 3 Q4. If we exchange the first line with the third line in the list2.txt file, how many lines are printed to the standard output? new list2.txt content: 2 eggs 1 loaf of bread 2 apples 3 7 4 O2 06 O 1 O 5 Problem 3 Q5. If we exchange the first line with the third line in the list2.txt file, how many lines are printed to the file listdiff.txt? new list2.txt content: 2 eggs 1 loaf of bread 2 apples 0 1 o 0 4 N 5 6 07 o 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!