Question: must submit your own work and only use cepts being taught in class. No break, no inue, no pass statement in your solutions. e all
must submit your own work and only use cepts being taught in class. No break, no inue, no pass statement in your solutions. e all problems in one file called Traversals.py 1. Average of numbers in a list Define and test (2 times) a value-returning function average(anyList) that calculates and returns the average of all items of a list of numbers, given as parameter. The function will return 0 if the list entered is empty. Use a for loop for the list traversal. For each test, what is the expected value of the function? Write your answer in a comment just above the respective function call. 2. Count Words with 'ea' Define and test (2 times) a value-returning function countWords(anyList) that counts and returns how many strings of a list of strings, given as parameter, contain a substring 'ea'. Use a while loop for the list traversal. For each test, what is the expected value of the function? Write your answer in a comment just above the respective function call. Challenges: a) Count words with substrings 'ea', each letter capitalized or not. b) Add a second parameter to your function that allows to specify any substring. 3. Print Long Words Define and test a void function printLongWords(anyList) that prints all items of a list of strings, given as parameter, that are longer than 3 characters. Use a for-loop over the range of the indices for your solution. Challenge: Add a second parameter to the function that allows to enter any length (not just 3 characters)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
