Question: A file's name is read from input. The file is opened and fig _ file is assigned with the file object. Each line in fig
A file's name is read from input. The file is opened and figfile is assigned with the file object. Each line in figfile contains an integer representing the number of figs bought in a day. Use a loop to read each line of figfile. Inside the loop, assign sumoffigs with the sum of all the integers in figfile.
Click here for exampleEx: If the input is datatxt and:
Contents of file datatxt
then the output is:
Total number of figs bought:
main.pydatatxtdatatxtdatatxt
figfile openinput
Your code goes here
figfile.close
printfTotal number of figs bought: sumoffigs
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
