Question: Matthew works as a software developer in UC Inc. He is developing an application based on the Python language in which he has created a

Matthew works as a software developer in UC Inc. He is developing an application based on the Python language in which he has created a file named test.txt. Now, he wants to open the file and display its content. He has written the following code:for line in open("test.txt"):print(line, end="")The file gets executed and displayed properly but is not closed properly. Which of the following code segments should Matthew use to avoid this issue?This type of question contains radio buttons and checkboxes for selection of options. Use Tab for navigation and Enter or space to select the option.optionAwith open("tset.txt") as f:for line in f:print(line, end="")optionBfor line in open("text.txt"):print(line, end="")optionCfor line in open("test.txt")print(line, end="")optionDwith open("test.txt") as f:for line in f:print(line, end="")

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!