Answered step by step
Verified Expert Solution
Link Copied!

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.

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Numerical Methods With Chemical Engineering Applications

Authors: Kevin D. Dorfman, Prodromos Daoutidis

1st Edition

1107135117, 978-1107135116

More Books

Students also viewed these Programming questions

Question

We are interviewing quite a few people, why should we hire you?

Answered: 1 week ago

Question

What is the purpose of the journal wizard?

Answered: 1 week ago

Question

Compute the LU decomposition of A 2 = [43] 6 13

Answered: 1 week ago