[Q2] Quack Family – Siblings (this is a practice question for an…
Question Answered step-by-step [Q2] Quack Family – Siblings (this is a practice question for an… [Q2] Quack Family – Siblings (this is a practice question for an exam)The ProblemA duck can usually raise 12 ducklings, which is quite a lot. In the Kingdom of Mallard, there is a culture of recording their own family tree. Some family trees can trace back hundreds of years of lineage, while others have records of only the latest generation.You have found some family trees online. While you were learning about their history, you had an idea to present the family tree interactively. Specifically, you would like to interactively count and identify the siblings and step-siblings of a given duck of interest.The provided data files present the details of each duck in a separate row in the following format:,
Siblings will be listed first, followed by step-siblings. Step-siblings will also be identified with the string (step) following their names. Regular English punctuation will need to be applied. For example, from the data of the sample file shown above:print(count_siblings(“family.dcf”, “Brian”)) # Brian has 3 siblings: Ryan, Melvin and Daffy(step). count_siblings(“family.dcf”, “Daffy”) # Daffy has 5 siblings: Stephen(step), Ryan(step), Chris(step), Brian(step) and Melvin(step). If the parameter filename is not a string type, then a TypeError exception is thrown with the contents of the exception being a string “parameter filename is not a string”.If the parameter name is not a string type, then a TypeError exception is thrown with the contents of the exception being a string “parameter name is not a string”.If the parameter name is not found in the file, then a ValueError exception is thrown with the contents of the exception being a string “name parameter not found in file”.If the file cannot be opened because it does not exist, you must catch the FileNotFoundError object and throw a new exception FileNotFoundError with the contents of the exception being the filename. Any other exception for failure to open a file is not caught. Computer Science Engineering & Technology Python Programming INFO 1110 Share QuestionEmailCopy link Comments (0)


