Python Program code to demonstratE Matrix Product

Publié le: 05 novembre 2022
sur la chaîne: 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


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Program code to demonstratE Matrix Product durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Tech Tips 05 novembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3 fois et il a aimé 0 téléspectateurs. Bon visionnage!