Starting from:

$29.99

CS104 Homework 05 Solution


1.  Please implement four methods (one method for each case a, b, c, d) that take a value and returns whether that value is in the gray zone or not (True or False). Verify your implementation by using the following sets:
A = { 2, 3, 4, 5, 6, 7, 8}
B = { 7, 8, 9, 10 }

2.  Implement a method that takes a matrix and a vector, calculates their product using list comprehension and returns the resulting list. We expect your method to be a single line method that uses list comprehension. The formula for matrix-vector is as follows:

3.  Please see the graph below. The graph consist of vertices (V = {A, B, C, D, E}) and edges that connect them to each other (E = {1, 2, 3, 4, 5, 6, 7}). Please use an appropriate container (list, tuple, set, dictionary) to model this graph. Implement two methods that uses this container. First method shall return the number of edges connected to a vertex. For example give_edges(“A”) shall return (4, 5, 6) as a tuple. Similarly give_vertices(2) shall return (“B”, “E”) as a tuple.

4.  We have the following dictionary given for English to French translation.
English French
bread pain
wine vin
bring apporter
I Je
eat mange
drink bois
John-Michael Jean-Michel
friends amis
and et
of du
red rouge
from de
town ville
we nous
Mary Marie
for pour
years ans
Please translate the following phrase using this dictionary. Please keep in mind that you’re expected to keep the layout and and punctuation marks as they are, and just translate the words.
John-Michael and, friends from town drink wine.
I eat bread!
For 5 years, we bring red wine from town, from Mary.

More products