python program of this question
"network.py'
class network(object):
"""docstring for Network"""
def __init__(self):
self.name={
'me':[['Rick',2],['Jamie',4],['Bryan',0],['Ray',0],['Bas',0],['Heather',8],['Patrick',2],['Derek',0],['Joshua',4]],
'Rick':[['Bryan',3],['Bas',3],['me',2]],
'Jamie':[['me',4],['Heather',9],['Bas',0]],
'Bryan':[['Ray',0],['Rick',3],['Bas',0]],
'Ray':[['Patrick',5],['Bas',3],['me',0]],
'Bas':[['me',0],['Ray',3],['Bryan',0],['Rick',3],['Jamie',0],['Heather',0],['Patrick',7]],
'Heather':[['me',8],['Jamie',9],['Bas',0],['Derek',2],['Joshua',6]],
'Patrick':[['me',2],['Ray',5],['Bas',7]],
'Derek':[['me',0],['Heather',2]],
'Joshua':[['me',4],['Bas',0],['Heather',6]]
}
'''' this method print the list of
all friend of each person '''
def list_of_frinend(self):
print("\n---------------list of all friend of each person -----------------")
for k,v in self.name.items():
print(k + '\t',end=' ')
for x in v:
print(x[0],end=' ')
print();
''' unique_friend_of_friend of each persom'''
def unique_friend_of_friend(self):
print("\n---------------unique friend of friend of each person-------------")
for k,v in self.name.items():
print(k + '\t:',end=' ')
S = set()
for x in v:
for y in self.name[x[0]]:
S.add(y[0])
print(S);
''' highest involed people in communication'''
def highest_involved(self):
print('\n-------------three highest involved people ------------------')
L = list()
for k,v in self.name.items():
l =list()
for x in v:
l.append(x[1])
L.append([k,max(l)])
def myFun(a):
return a[1]
L.sort(key=myFun)
print(L[-3:])
def list_zero_communication(self):
print('\n---------------------------list of those people who have zero communication')
L = list()
for k,v in self.name.items():
l =list()
for x in v:
l.append(x[1])
if min(l) ==0:
L.append(k)
print(L)
def average_number_of_friend(self):
print('\n-------------average number of friend---------------')
sum=0;
for v in self.name.values():
sum = sum+len(v);
print(sum//len(self.name))
def more_than_4_friends(self):
print('\n-------------name of person who have more than four friend------------------')
for k,v in self.name.items():
if len(v)>4:
print(k,end=' ');
x = network();
x.list_of_frinend();
x.unique_friend_of_friend();
x.highest_involved();
x.list_zero_communication();
x.average_number_of_friend();
x.more_than_4_friends();
print("\n\n\nEND Program\n\n")
you can run this program like
python3 newtwork.py
this program output is follow
Python code Write a Python program for each of the following: The following is a social...
Java program
The popular social network Facebook ™ was founded by Mark Zuckerberg and his classmates at Harvard University in 2004. At the time, he was a sophomore studying computer science. Design and implement an application that maintains the data for a simple social network. Each person in the network should have a profile that contains the person's name, optional image, current status, and a list of friends. Your application should allow a user to join the network, leave the...
Hi, I have a python coding questions and would need help: Count the neighbors of each node in a graph. input graph is a multi-dimensional list Let's say I want to have each person's friends count: input (list of list): [[A, B], [B, C], [B, D], [E]], output (dict): {A:1, B: 3, C:1, D:1, E:0} assume you won't get a repeat pair like [A,B] and [B,A], and neither will there be more than 2 people in a relationship. I want...
write the solution of the program by python 3 language : I need the program using list : Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the guard....
Write a Python program to solve the following problem: Information is available about the latest municipal election. For each voter, the following data is given: voter id number age of voter the ward number (1, 2, 3 or 4) in which the voter resides the name of the person the voter selected for mayor Input this information and compute and output the following statistics: the total number of voters the number of people under the age of 25 who voted...
This program is in python. We are not allowed "exit()"
In this part, you will write a simple children's game. You will ask the user to enter five names of friends. Then, you will ask three questions 1. Which of these people would you give your last piece of candy?" 2. "With which of these people would you go on a 12 hour road trip?" 3. "With which of these people would you play tennis on a yacht? At the...
Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...
Write a program that does the following in Python Code: Stores the following three lists: last_name = ["Smith", "Jones", "Williams", "Bailey", "Rogers", "Pyle", "Rossington"] first_name =["Lisa", "Bill", "Jay", "Sally", "Walter","Jake","Gary"] phone_number =["240-233-1921", "301-394-2745", "571-321-8934", "703-238-3432", "703-947-9987", "301-945-3593", "240-671-3221"] Has a function named combine_lists() that takes in last_names, first_names and phone_numbers as lists and returns a dictionary called phone_book that uses last_name as the key and a list consisting of first_name and phone_number. Has a main function that iterates through the...
Write, test and document a Python program, in a file called MarsCoins.py, to solve the following problem Marvin from Mars has a jar full of martian currency (Maruvians, Caruvians, Taruvians and Paruvians). The breakdown of the currency units on Mars is as follows: The single smallest unit of currency is a Paruvian 6 Paruvians 1 Taruvian 12 Paruvians 1 Caruvian 24 Paruvians1 Maruvian Marvin wants to share his money with his friends but he doesn.t want to carry around all...
Write a python program that will create a histogram of the
number of times each character occurs in a file. Check
https://en.wikipedia.org/wiki/Histogram and
http://interactivepython.org/runestone/static/thinkcspy/Functions/ATurtleBarChart.html
for help. Your program will read any input text file and print the
histogram. If you have a huge file you should have a graph similar
to:
Note the y-axis shows the percentage of each
letter. The height of each bar is percentage of that
letter. Program MUST show the graph with percentage marks
on y-axis...
It's important project. I need a help. Will give up vote for helping! Please use Java !!!!! Need clearly written java program code and sample output!!!!!! The popular social network Facebook TM was founded by Mark Zuckerberg and his classmates at Harvard University in 2004. At the time, he was a sophomore studying computer science. Design and implement an application that maintains the data for a simple social network. Each person in the network should have a profile that contains...