Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. 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
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started