{"id":25880,"date":"2021-12-16T09:20:46","date_gmt":"2021-12-16T03:50:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=25880"},"modified":"2021-12-16T09:20:46","modified_gmt":"2021-12-16T03:50:46","slug":"python-program-to-perform-multiplication-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-perform-multiplication-with-examples\/","title":{"rendered":"Python Program to Perform Multiplication with Examples"},"content":{"rendered":"

Given two numbers and the task is to find the Multiplication of two numbers.<\/p>\n

Also, given a list and the task is to find the Multiplication of all the elements in a given list.<\/p>\n

Here we also use the Numpy module to perform the\u00a0 Multiplication<\/p>\n

Python numpy.prod() Function:<\/strong><\/p>\n

prod() in numpy accepts a list as an argument and returns the product of all the elements in the list. This function is quite useful and saves a significant amount of code. To use numpy.prod(), simply import numpy<\/strong>().<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given first number = 2\r\nGiven second number = 3<\/pre>\n

Output:<\/strong><\/p>\n

The Multiplication of given two numbers { 2 * 3 } =  6<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [4, 7, 3, 1, 5]<\/pre>\n

Output:<\/strong><\/p>\n

The Multiplication of all the elements of a given list [4, 7, 3, 1, 5] = \r\n420<\/pre>\n

Program to Perform Multiplication in Python with Examples<\/h2>\n

 <\/p>\n

Method #1: Using (*) Operator (Static Input)<\/h3>\n

1) Multiplication using Functions<\/strong><\/p>\n

Approach:<\/strong><\/p>\n