Question: File name ingredients _ data and value one _ ingredient _ value are read from input. Perform the following tasks: Open the file ingredients _
File name ingredientsdata and value oneingredientvalue are read from input. Perform the following tasks:
Open the file ingredientsdata with the w update mode for reading and writing at the same time. Assign ingredientsfile with the opened file.
Write oneingredientvalue to ingredientsfile, overwriting any existing contents.
Call ingredientsfile's flush
Click here for example
Ex: If the input for ingredientsdata is datatxt oneingredientvalue is fig, and:
Contents of file datatxt
egg
leek
then the output is:
fig
Note: The challenge activity will read and output the file named ingreingredientsdata input
oneingredientvalue input
you code goes here...
# When a file is in update mode,
# seek rewinds the file to enable reading from the beginning
ingredientsfile.seek
filedata ingredientsfile.read
printfiledata
ingredientsfile.closedientsdata.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
