Python Program code to demonstratE Matrix Product

Published: 05 November 2022
on channel: Tech Tips
3
0

Python3 code to demonstrate
Matrix Product
Using list comprehension + loop

getting Product


def prod(val):
res = 1
for ele in val:
res *= ele
return res


initializing list
test_list = [[1, 4, 5], [7, 3], [4], [46, 7, 3]]

printing original list
print("The original list : " + str(test_list))

using list comprehension + loop
Matrix Product
res = prod([ele for sub in test_list for ele in sub])

print result
print("The total element product in lists is : " + str(res))
Output :

The original list : [[1, 4, 5], [7, 3], [4], [46, 7, 3]]
The total element product in lists is : 1622880


On this page of the site you can watch the video online Python Program code to demonstratE Matrix Product with a duration of hours minute second in good quality, which was uploaded by the user Tech Tips 05 November 2022, share the link with friends and acquaintances, this video has already been watched 3 times on youtube and it was liked by 0 viewers. Enjoy your viewing!