Question: A Caution: You are NOT allowed to import any modules in your solution. In this problem, you will start with a program (a python file

 A Caution: You are NOT allowed to import any modules inyour solution. In this problem, you will start with a program (apython file with a main method that will be executed when you

A Caution: You are NOT allowed to import any modules in your solution. In this problem, you will start with a program (a python file with a main method that will be executed when you run the code) that reads data from a file and stores it as a list of strings. The code for loading the date from a file is provided for you. Each line in the file will be one string in the list. Each line has the following format: name, age, meta, usernamel@domaini, username2@domain2, usernamen@domains Here, the number of email addresses in a given line will be at least 1 (but there is no upper limit). Each line can have a different number of email addresses. The meta field is some other data that is stored (could be anything, including empty). None of name, age, meta, usernamex@domainX will contain a comma. All commas in each line separate data. Essentially, you have a list of people with their names, ages, some extra (meta) information, and their email addresses. Your task will be to complete two functions: findByDomain() and aveNumberOfEmails (). findByDomain (domain, data) Takes a string called domain (like carleton.ca, a string) and the data (list of strings in the format described above) as input. Returns a list of strings. Each string has the form name:number' where name is a name and number is the number of emails that person has with the given domain. Note that an email with a given domain might not use the exact string as provided but should still be a 'match'. For example, "abc@cmail.carleton.ca' and 'x.yz@catleton.ca' both have the 'carleton.ca' domain. Likewise, 'a@gmail.com', 'b@hotmail.com' and 'c@live.com' all have the .com' in their domains and would be a match for.com'. Note that these last THREE emails and fe@comcast.ca' would all be a match for 'com' (without the dot). For example, >>> data = ['cat, 12, no meta, c@carleton.ca, c@cmail.carleton.ca, c@yahoo.ca '] >>> findByDomain('carleton.ca', data) ['cat:2'] >>> findByDomain ('live.com', data) [] >>> findByDomain ('yahoo', data) ['cat:1'] emailsByAge (lower, upper, data) Takes two integers and a list of strings as input. The inputs, lower and upper, will satisfy 1 >> data = ['cat, 12, no meta, c@carleton.ca, c@cmail.carleton.ca, c@yahoo.ca '] >>> emailsByAge (11, 15, data) [11, 0, 3.0, 0, 0, 0] Note that the average number of email addresses if there are no people of a given age is zero. For both functions, you can assume that the names in the data list are unique. You can also assume that the age of everyone is strictly between 0 and 102. Add your functions to the provided process.py file and include this in your submission zip file. You can modify the main method to help you test your code. We will not run your main method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!