bluebell94

Results 10 comments of bluebell94

def fib_check(n,expected): if fib (n) == expected: return True else: return False def fib(n): if (n

from networkx import MultiGraph team_coworkers=MultiGraph() team_coworkers.add_node("Tim Berners-Lee") team_coworkers.add_node("Christian Brizer") team_coworkers.add_node("Tom Heath") team_coworkers.add_node("Sören Auer") team_coworkers.add_node("Lalann Kagul") team_coworkers.add_node("James A. Hendler") team_coworkers.add_edge("Tim Berners-Lee", "Christian Brizer", weight=17) team_coworkers.add_edge("Tim Berners-Lee","Tom Heath", weight=17) team_coworkers.add_edge("Tim Berners-Lee", "Sören...

set_hobbits=({"Frodo","Sam","Pippin","Merry"}) set_magicians=({"Saruman","Gandalf"}) dict_protagonists=dict() dict_protagonists["hobbit"]=set_hobbits dict_protagonists["magician"]=set_magicians print(dict_protagonists) At the end to each of the names in the set_hobbits is assigned key "hobbit", correspondingly to each name in the set_magicians is asssigned...

def exp_check(n,e,expected): if exp(n,e) == expected: return True else: return False def exp(n,e): if (e==0): result=1 else: result=n*exp(n,e-1) return result print (exp(2,3)) {8) print(exp(93,0)) {1) print(exp_check(3,4,81)) {True) print(exp_check(17,1,17)) {True) print(exp_check(2,0,1))...

from networkx import MultiDiGraph movie_stars = MultiDiGraph() movie_stars.add_node("a",weight="Ocean's Twelve") movie_stars.add_node("b",weight="Fight Club") movie_stars.add_node("c",weight="Dark Shadows") movie_stars.add_node(1, weight="Brad Pitt") movie_stars.add_node(2, weight="George Clooney") movie_stars.add_node(3, weight="Eva Green") movie_stars.add_node(4, weight="Catherine Zeta-Jones") movie_stars.add_node(6, weight="Helena Bonham Carter") movie_stars.add_edge(1,"a")...

# initial stage of the set protagonists= ({"Bilbo", "Frodo", "Sam", "Pippin", "Merry"}) protagonists.remove("Bilbo")- will remove "Bilbo" # current status of the set - ({"Frodo", "Sam", "Pippin", "Merry"}) protagonists.add("Galadriel")- will add...

1 | protagonists=set() 2 | protagonists.add("Bilbo") 3 | protagonists.add("Frodo") 4 | protagonists.add("Sam") 5 | protagonists.add("Pippin") 6 | protagonists.add("Merry") 7 | print (protagonists) Final set, containing ["Bilbo", "Merry", "Sam", "Pippin","Frodo"]

my_queue = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"])- initial state of the queue By executing my_queue.popleft() - we remove "Draco" from the queue, rule of the queue FIFO - current state...

protagonist_list ={"Harry","Draco","Hermione","Ron","Severus"}   | 1 | protagonist_list=list() -- | -- | -- 2 | protagonist_list.append("Harry") 3 | protagonist_list.append("Draco") 4 | protagonist_list.append("Hermione") 5 | protagonist_list.append("Ron") 6 | protagonist_list.append("Severus") 7 | protagonist_list.sort() 8...

my_stack = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"]) - initial state of the stack by executing my_stack.pop() for the 1st time- we have to eliminate the lastly added element on the...