Answered You can hire a professional tutor to get the answer.

QUESTION

import random class Person(object): friend = def __init__(self, ssn = '', fname = '', lname= '', dob = 0, state = '', friend = ): self.ssn = ssn...

I am working in Python and the question is for each person in the person list choose a number of friends (minimum is zero and maximum is size/200).  Assume this number is x.  Now you need to generate x locations of the friends and add them as friends to the list of friends of the current person.  The attached file shows that I have generated a random number using the random library.  However, how do I randomly select lines from the file and assign them to the friends list in the class.  I have attached both my code and the file I am using.

Once I complete this one, I will need to write a function that will sort the list by the number of friends in a descending order.  I think I have a function that will do that, but I am unable to test it, because I don't think I am doing the first part correctly.  Then finally, for each person, I will need to find all people who have that person as a friend.  I think if I can figure out the first part, I can do the rest, but I am stuck on properly assigning friends.

  • Attachment 1
  • Attachment 2
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question