Q. What is the effect of print(‘test’, file=open(‘output.txt’, ‘w’))?

A
Prints to console
B
Writes to output.txt
C
Creates an error
D
Appends to output.txt
Solution:

file=open(‘output.txt’, ‘w’) redirects output to the file, overwriting it.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!