Quiz 11

Question 1: Create a function called readNumbersFromFile that receives as a parameter a string with the name of a file (located in the same directory) of numbers. The file has a number on each line (assume all integers).

The function will open the file, read the values and then print (that is right, this function returns no values) the following:

  • The total of the values
  • The number of values (same as number of lines btw)
  • The arithmetic mean (average) of the values
  • The standard deviation of the values.

Link to the answer for question 1: https://github.com/yorchpave95/Quiz-11/blob/master/Quiz%2011%20q1.py

Question 2: Write a function called check_banana 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).

Link to the answer for question 2: https://github.com/yorchpave95/Quiz-11/blob/master/Quiz%2011%20q2.py

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

Comments are closed.