Start with some file-processing exercises that illustrate the following.
read(), readline() & readlines()write()Compare and contrast the following file-reading code segments.
with open('scores.txt') as f:
for line in f:
print(line.strip(), end=' ')
f = open('scores.txt')
lines = f.readlines()
for line in lines:
print(line.strip(), end=' ')
Assuming that f refers to the file shown here and has just been opened, what does skip() return?
Songs Chosen #Game names for the songs #All ridiculously good soundtracks Sep 17, Chrono Cross Sep 19, Zelda 3def skip(f): line = f.readline() line = f.readline() while line.startswith('#' ): line = f.readline() return f.readline()
Using a file that lists a set of movies from the IMDB, “imdb.txt”, compute and print the number of titles that have the word “Moon” or the word “Sun” in them. Assume that each line in the file has just the movie title.