Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You have to create a program that writes the numbers - 5 , 2 and 3 to a file output.txt , then later reads this
You have to create a program that writes the numbers and to a file output.txt then later reads this file, sums the numbers, and then adds the sum back to the file. Which code applies write and read methods appropriately to perform this task?
data
fout opendataoutput.txtw
for val in data:
fout.writestrval
fout.close
data
fin opendataoutput.txtr
for values in fin:
val values.replace
dataappendval
fin.close
sum sumdata
mysum opendataoutput.txtw
fout.writestrmysum
fout.close
data
fout opendataoutput.txtr
for val in data:
fout.writeval
fout.close
data
fin opendataoutput.txtw
for values in fin:
val values.replace
dataappendintval
fin.close
mysum sumdata
fout opendataoutput.txta
fout.writestrmysum
fout.close
data
fout opendataoutput.txtw
for val in data:
fout.writestrval
fout.close
data
fin opendataoutput.txtr
for values in fin:
val values.replace
dataappendintval
fin.close
mysum sumdata
fout opendataoutput.txta
fout.writestrmysum
fout.close
data
fout opendataoutput.txtr
for val in data:
fout.writestrval
fout.close
data
fin opendataoutput.txtw
for values in fin:
val values.replace
dataappendintval
fin.close
mysum sumdata
fout opendataoutput.txta
fout.writestrmysum
fout.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