Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a file named rainfall.txt that contains records of rainfall. Each line in the file contains the name of a place, a date and the
Consider a file named rainfall.txt that contains records of rainfall. Each line in the file contains the name of a place, a date and the recorded rainfall in mm Given below is a sample content of this file:
Gordons Bay,
Johannesburg,
Hammanskral,
Mamelodi,
Port Elizabeth,
a State the format of the data in this file. marks
b Which function can be used to open the file rainfall.txt for reading only? marks
c Which function can be used to open the file rainfall.txt for writing data at the end of the file without deleting the existing content? marks
d Assume that the file was successfully opened for reading. Which function can be used to read a line in the file and return an array of three substrings by splitting this line? marks
e Write code to copy the contents of rainfall.txt to rainfallnew.txt marks
f Write code to rename the file rainfall.txt to rainfallold.txt marks
g Write code to delete the file rainfallold.txt marks
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