199k views
5 votes
What happens when the following code segment executes if test.txt does not exist?:
A,B,C,D?

What happens when the following code segment executes if test.txt does not exist?: A-example-1

1 Answer

4 votes

The answer is A.

In Python, if test.txt does not exists then opening it with mode 'w' will create new empty file.

User Farrad
by
5.3k points