In this quiz we had to write 2 programs which do the following:

  • Question 1:  Write a function called calculateE that receives a single float parameter accuracy and calculates the value of e using using sufficient terms (ie: there are 4 terms shown above for n equal to 0, 1, 2, 3) until the difference between two successive calculations differ by LESS than the parameter accuracy.

 

  • Question 2: Write a function called checkBanana that receives a single parameter of type string that is the name of a file in the same directory as the program. The function opens that file of text and counts the number of times that the string “banana” appears. For full marks it should ignore case (so count Banana, BANANA, bAnAnA regardless of mix of upper and lower case characters.

 

Here is the link to my Github Account where you will be able to find the codes of this two questions that you can see above:

Click here to see the answers.

 

Also I want to thank Miguel Angel for his post about this quiz, it really helped me a lot!

Stay true.

-The Admin.

CC BY 4.0 Quiz #11 by esaupreciado is licensed under a Creative Commons Attribution 4.0 International License.