findFirst("The tragedy of Romeo and Juliet", "m") returns findFirst("The tragedy of Romeo and Juliet", "z") returns findFirst("The tragedy of Romeo and Juliet", "t") returns
digitsSmallerThanSum(55555555, 32) digitsSmallerThanSum(55555555, 5)
fileFun.py
knows how to find the data file simple.txt
?
printLines
does (how are the lines printed)
and why there is the print statement after the for loop.
numberLines
that returns the number
of lines in the given file. This function should open the file, calculate
the number, close the file and return the answer.
numberWords
that returns the number
of words in the given file. This function should open the file, calculate
the number, close the file and return the answer.
numberOfWord
that returns the number
of times the parameter word
appears in the given file. This function should open the file, calculate
the number, close the file and return the answer.
athletes.txt
.
If you were going to process each line in athletes by spliting the line into parts, what separator should you use?
athletes.txt
and consider the function
listAthletes
that has two parameters, the filename and the sport.
Suppose one line of the file is put in the variable line. Since lines in the file have carriage returns, what would be the line of code that takes this line and strips off the carriage return and breaks the line into parts into a list?
steps
in the trials
function to 6 describe how the results printed are different and
why they are different.
while sum(locs) !=
2*n+1
in the loop in walk
works.