Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do TASK B, the COUSIN DEGREE one Code for reading the family list: def read_family(filename): family = [] f = open(filename, r) for line

Please do TASK B, the COUSIN DEGREE one

Code for reading the family list:

def read_family(filename): family = [] f = open(filename, "r") for line in f: entry = line.strip().split(",") for i in range(3): entry[i] = entry[i].strip() if entry[i] == '': entry[i] = None family += [entry] return family

Family text file provided:

Buffo Boffin,, Ivy Goodenough,, Madoc Brandybuck, Gormadoc Brandybuck, Malva Headstrong Sadoc Brandybuck, Gormadoc Brandybuck, Malva Headstrong Marmadoc Brandybuck, Madoc Brandybuck, Hanna Goldworthy Salvia Brandybuck, Sadoc Brandybuck, Theobald Bolger, Gundabald Bolger, Salvia Brandybuck Wilibald Bolger, Theobald Bolger, Nina Lightfoot Wilimar Bolger, Wilibald Bolger, Prisca Baggins Heribald Bolger, Wilibald Bolger, Prisca Baggins Nora Bolger, Wilibald Bolger, Prisca Baggins Gundolpho Bolger,, Alfrida of the Yale,, Gundahad Bolger, Gundolpho Bolger, Alfrida of the Yale Gundabald Bolger, Gundahad Bolger, Rudolph Bolger, Gundolpho Bolger, Alfrida of the Yale Gundahar Bolger, Gundolpho Bolger, Alfrida of the Yale Fastolph Bolger, Rudolph Bolger, Cora Goodbody Adaldrida Bolger, Gundahar Bolger, Dina Diggle Gorbadoc Brandybuck, Marmadoc Brandybuck, Adaldrida Bolger Adalgar Bolger, Gundahar Bolger, Dina Diggle Ruby Bolger, Adalgar Bolger, Rudigar Bolger, Adalgar Bolger, Rudibert Bolger, Adalgar Bolger, Bosco Boffin, Buffo Boffin, Ivy Goodenough Basso Boffin, Buffo Boffin, Ivy Goodenough Briffo Boffin, Buffo Boffin, Ivy Goodenough Berylla Boffin, Buffo Boffin, Ivy Goodenough Otto Boffin, Bosco Boffin, Hugo Boffin, Otto Boffin, Lavender Grubb Ponto Baggins I, Balbo Baggins, Berylla Boffin Mungo Baggins, Balbo Baggins, Berylla Boffin Largo Baggins, Balbo Baggins, Berylla Boffin Pansy Baggins, Balbo Baggins, Berylla Boffin Lily Baggins, Balbo Baggins, Berylla Boffin Polo Baggins, Ponto Baggins I, Mimosa Bunce Rosa Baggins, Ponto Baggins I, Mimosa Bunce Bungo Baggins, Mungo Baggins, Laura Grubb Belba Baggins, Mungo Baggins, Laura Grubb Longo Baggins, Mungo Baggins, Laura Grubb Linda Baggins, Mungo Baggins, Laura Grubb Bilbo Baggins, Bungo Baggins, Belladonna Took Fosco Baggins, Largo Baggins, Tanta Hornblower Isengrim Took II,, Isumbras Took III, Isengrim Took II, Ferumbras Took II, Isumbras Took III, Bandobras Took, Isumbras Took III, Fortinbras Took I, Ferumbras Took II, Gerontius Took, Fortinbras Took I, Isengrim Took III, Gerontius Took, Adamanta Chubb Hildigard Took, Gerontius Took, Adamanta Chubb Isumbras Took IV, Gerontius Took, Adamanta Chubb Isembold Took, Gerontius Took, Adamanta Chubb Hildifons Took, Gerontius Took, Adamanta Chubb Isembard Took, Gerontius Took, Adamanta Chubb Hildibrand Took, Gerontius Took, Adamanta Chubb Donnamira Took, Gerontius Took, Adamanta Chubb Hildigrim Took, Gerontius Took, Adamanta Chubb Belladonna Took, Gerontius Took, Adamanta Chubb Mirabella Took, Gerontius Took, Adamanta Chubb Fortinbras Took II, Isumbras Took IV, Ferumbras Took III, Fortinbras Took II, Lalia Clayhanger Flambard Took, Isembard Took, Adelard Took, Flambard Took, Everard Took, Adelard Took, Reginard Took, Adelard Took, Sigismond Took, Hildibrand Took, Rosamunda Took, Sigismond Took, Jessamine Boffin, Hugo Boffin, Donnamira Took Herugar Bolger, Rudigar Bolger, Belba Baggins Odovacar Bolger, Herugar Bolger, Jessamine Boffin Fredegar Bolger, Odovacar Bolger, Rosamunda Took Estella Bolger, Odovacar Bolger, Rosamunda Took Posco Baggins, Polo Baggins, Asphodel Brandybuck, Gorbadoc Brandybuck, Mirabella Took Rorimac Brandybuck, Gorbadoc Brandybuck, Mirabella Took Amaranth Brandybuck, Gorbadoc Brandybuck, Mirabella Took Saradas Brandybuck, Gorbadoc Brandybuck, Mirabella Took Dodinas Brandybuck, Gorbadoc Brandybuck, Mirabella Took Dinodas Brandybuck, Gorbadoc Brandybuck, Mirabella Took Primula Brandybuck, Gorbadoc Brandybuck, Mirabella Took Porto Baggins, Posco Baggins, Gilly Brownlock Ponto Baggins II, Posco Baggins, Gilly Brownlock Peony Baggins, Posco Baggins, Gilly Brownlock Milo Burrows, Rufus Burrows, Asphodel Brandybuck Moro Burrows, Milo Burrows, Peony Baggins Myrtle Burrows, Milo Burrows, Peony Baggins Minto Burrows, Milo Burrows, Peony Baggins Mosco Burrows, Milo Burrows, Peony Baggins Adalgrim Took, Hildigrim Took, Rosa Baggins Paladin Took II, Adalgrim Took, Esmeralda Took, Adalgrim Took, Pimpernel Took, Paladin Took II, Eglantine Banks Pervinca Took, Paladin Took II, Eglantine Banks Peregrin Took I, Paladin Took II, Eglantine Banks Pearl Took, Paladin Took II, Eglantine Banks Faramir Took I, Peregrin Took I, Diamond Took Saradoc Brandybuck, Rorimac Brandybuck, Menegilda Goold Merimac Brandybuck, Rorimac Brandybuck, Menegilda Goold Meriadoc Brandybuck, Saradoc Brandybuck, Esmeralda Took Berilac Brandybuck, Merimac Brandybuck, Seredic Brandybuck, Saradas Brandybuck, Doderic Brandybuck, Seredic Brandybuck, Hilda Bracegirdle Ilberic Brandybuck, Seredic Brandybuck, Hilda Bracegirdle Celandine Brandybuck, Seredic Brandybuck, Hilda Bracegirdle Drogo Baggins, Fosco Baggins, Ruby Bolger Dora Baggins, Fosco Baggins, Ruby Bolger Dudo Baggins, Fosco Baggins, Ruby Bolger Frodo Baggins, Drogo Baggins, Primula Brandybuck Daisy Baggins, Dudo Baggins, Tosto Boffin, Griffo Boffin, Daisy Baggins Adalbert Bolger, Rudibert Bolger, Amethyst Hornblower Filibert Bolger, Adalbert Bolger, Gerda Boffin Otho Sackville-Baggins, Longo Baggins, Camellia Sackville Lobelia Sackville-Baggins, Longo Baggins, Camellia Sackville Lotho Sackville-Baggins, Otho Sackville-Baggins, Lobelia Sackville-Baggins Odo Proudfoot, Bodo Proudfoot, Linda Baggins Olo Proudfoot, Odo Proudfoot, Sancho Proudfoot, Olo Proudfoot,

image text in transcribed

Task B: Consin Degree (6 Marks) Implement a function cousin degree(pt. p. tandly) with the following predicatie Impat: Two string representing two time panip and a family tree databasily Output: An interesting the minimum distance consin relationship between pt and p, as follows ..pt a presibling 1. plan are con some positive integer, if pand pareathcoming of . if pip have to contesinoribling laticeship For example, cousin.degree(pl. p2. family will have as follow >>> bobbitsrondranilyhobbie-fily, txt") >>> Csin degree("Ninto Burrovat, Myrtle Burrows, hobbita) 0 >>> osin.degree"Estella Holger Meriadoc Brandybuca', tobbit) 9 >>> cousin degree Frodo Baggina', 181160 Begina', hobbits)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions