Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Writing and reading files is an important aspect of many programs. Suppose you have to create a program that writes the number 0 to a
Writing and reading files is an important aspect of many programs. Suppose you have to create a program that writes the number to a file coutput.txt then later reads this file, and then adds the number back to the file.
Which code applies write and read methods appropriately to perform this task?
a
dataw
fout opencoutput.txtr
for val in dataw:
fout.writeval
fout.close
datar
fin opencoutput.txtw
for values in fin:
val values
datarappendintval
fin.close
b
dataw
fout opencoutput.txtw
for val in dataw:
fout.writestrval
fout.close
datar
fin opencoutput.txtw
for values in fin:
val values
datarappendval
fin.close
c
dataw
fout opencoutput.txtr
for val in dataw:
fout.writestrval
fout.close
datar
fin opencoutput.txtw
for values in fin:
val values
datarappendintval
fin.close
d
dataw
fout opencoutput.txtw
for val in dataw:
fout.writestrval
fout.close
datar
fin opencoutput.txtr
for values in fin:
val values
datarappendintval
fin.close
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started