python 3 and above, using dictionaries for these particular questions, also cann
ID: 3812864 • Letter: P
Question
python 3 and above, using dictionaries for these particular questions, also cannot use def. (myprogramminglab)
1) Given a variable, province_premier, that is associated with a dictionary that maps the province names to the names of province premiers, associate with premier_province a dictionary that is the inverse of province_premier, i.e. one that maps names of premiers to province names.
2)Given a variable , polygon_sides, that is associated with a dictionary that maps names of polygons to number of sides, create a new dictionary that maps number of sides to polygon names, and associate it with a variable n_polygons.
Explanation / Answer
# 3x3 matrix
X = [[12,7,3],
[4 ,5,6],
[7 ,8,9]]
# 3x4 matrix
Y = [[5,8,1,2],
[6,7,3,0],
[4,5,9,1]]
# result's 3x4
result = [[0,0,0,0],
[0,0,0,0],
[0,0,0,0]]
# restate through rows of X
for i in range(len(X)):
# restate through columns of Y
for j in range(len(Y[0])):
# restate through rows of Y
for k in range(len(Y)):
result[i][j] += X[i][k] * Y[k][j]
for r in result:
print(r)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.