Question: Write a function products_and_sums (pairs) that takes as a parameter a list of two-element numeric tuples. The function returns a new list of 2-element

Write a function products_and_sums (pairs) that takes as a parameter a list of two-element numeric tuples.

Write a function products_and_sums (pairs) that takes as a parameter a list of two-element numeric tuples. The function returns a new list of 2-element tuples of the same length, where each of the new tuples contains the product and sum of the elements in the input tuple. More formally, if the ith element of the list pairs is (a, b), then the th element of the returned list is (a*b;, ai + bi) In the example table below, the parameter list is [(5, 3), (2, 7)] and the function computes the result [(5 * 3, 5 + 3), (2 * 7, 2+7)] which evaluates to [(15, 8), (14, 9)]. For example: Test pairs [(5, 3), (2, 7)] print (products_and_sums (pairs)) = Result [(15, 8), (14, 9)]

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

python def productsandsumspairs Returns a list of tuples containing the product and sum of the elements in each tuple in the input list Args pairs A l... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!