Python being the language of magicians can be used to perform many tedious and repetitive tasks in a easy and concise manner and having the knowledge to utilize this tool to the fullest is always useful. One such small application can be finding product of squares of list in just one line. Let’s discuss certain ways in which this can be performed.

**Method #1 : Using reduce() + lambda**

The power of lambda functions to perform lengthy tasks in just one line, allows it combined with reduce which is used to accumulate the subproblem, to perform this task as well. Works with only Python 2.

`# Python code to demonstrate ` `# Product of Squares in List ` `# using reduce() + lambda ` ` ` `# initializing list ` `test_list ` `=` `[` `3` `, ` `5` `, ` `7` `, ` `9` `, ` `11` `] ` ` ` `# printing original list ` `print` `(` `"The original list is : "` `+` `str` `(test_list)) ` ` ` `# using reduce() + lambda ` `# Product of Squares in List ` `res ` `=` `reduce` `(` `lambda` `i, j: i ` `*` `j` `*` `j, [test_list[:` `1` `][` `0` `]` `*` `*` `2` `]` `+` `test_list[` `1` `:]) ` ` ` `# printing result ` `print` `(` `"The product of squares of list is : "` `+` `str` `(res)) ` |

*chevron_right*

*filter_none*

**Output :**

The original list is : [3, 5, 7, 9, 11] The product of squares of list is : 108056025

**Method #2 : Using map() + loop**

The similar solution can also be obtained using the map function to integrate and external product function to perform the product of the squared number.

`# Python3 code to demonstrate ` `# Product of Squares in List ` `# using sum() + max() ` ` ` `# getting Product ` `def` `prod(val) : ` ` ` `res ` `=` `1` ` ` `for` `ele ` `in` `val: ` ` ` `res ` `*` `=` `ele ` ` ` `return` `res ` ` ` `# initializing list ` `test_list ` `=` `[` `3` `, ` `5` `, ` `7` `, ` `9` `, ` `11` `] ` ` ` `# printing original list ` `print` `(` `"The original list is : "` `+` `str` `(test_list)) ` ` ` `# using sum() + max() ` `# Product of Squares in List ` `res ` `=` `prod(` `map` `(` `lambda` `i : i ` `*` `i, test_list)) ` ` ` `# printing result ` `print` `(` `"The product of squares of list is : "` `+` `str` `(res)) ` |

*chevron_right*

*filter_none*

**Output :**

The original list is : [3, 5, 7, 9, 11] The product of squares of list is : 108056025

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- Python | Sum of squares in list
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of list
- Python | Convert List of String List to String List
- Python Program for Sum of squares of first n natural numbers
- Circle of Squares using Python
- Python Bokeh - Plotting Squares with Xs on a Graph
- Python Bokeh - Plotting Squares with Dots on a Graph
- Python Bokeh - Plotting Squares with Crosses on a Graph
- Python Bokeh - Plotting Squares on a Graph
- Python | Construct Cartesian Product Tuple list
- Python - Product of consecutive pairs in list
- Python | Sliced Product in List
- Python | Product of Prefix in list
- Python | Column Product in List of lists
- Python | Product of kth column in List of Lists
- Python - Kth Column Product in Tuple List
- Python - Dictionary Key's Product in list
- Python - Suffix Product in list
- Python - Minimum Product Pair in List

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.