Method # 1: Using zip ()
+ expression generator + tuple()
A combination of the above functions can be used to completing this task. In this, we use a generator expression to provide the logic for the multiplication and concurrent connection of the elements is done using zip ()
. The result is converted to the form tuple ()
using tuple ()
.

Output:
The original tuple: (1, 5, 7, 8, 10) Resultant tuple after multiplication: (5 , 35, 56, 80)
Method # 2: Using tuple () + map ()
+ lambda
A combination of the above functions can also help accomplish this task. In this, we execute the logic of multiplication and binding using a lambda function. map ()
is used to iterate over each element and finally converted with tuple ()
.
# Python3 code to demonstrate how it works
# Multiply adjacent elements
# using tuple () + map () + lambda
# initialize the tuple
test_tup
=
(
1
,
5
,
7
,
8
,
10
)
# print the original tuple
print
(
"The original tuple:"
+
str
( test_tup))
# Multiply adjacent elements
# using tuple () + map () + lambda
res
=
tuple
(
map
(
lambda
i, j: i
*
j, test_tup [
1
:], test_tup [:

1
]))
# print result
print
(
"Resultant tuple after multiplication:"
+
str
(res))
Exit:
The original tuple: (1, 5, 7, 8, 10) Resultant tuple after multiplication: (5, 35, 56, 80)
Mastering regular expressions by Jeffrey Friedl, 3rd edition. Regular expressions are an extremely powerful tool for manipulating text and data. They are standard features today in a variety of pop...
05/09/2021
Introduction to Machine Learning with Python: A Guide for Data Scientists 1st Edition. Machine learning has become an integral part of many commercial applications and research projects, but this f...
05/09/2021
This book is an indispensable guide focuses on Machine Learning and R Programming, in an instructive and conversational tone which helps them who want to make their career in Big Data Analytics/ Data ...
10/07/2020
The big data era is upon us: data are being generated, analyzed, and used at an unprecedented scale, and datadriven decision making is sweeping through all aspects of society. Since the value of data...
10/07/2020