Question: Please help me figure out this computer science problem (python): In this task, you will write two functions that will be useful later. The first

Please help me figure out this computer science problem (python): In this task, you will write two functions that will be useful later. The first function add_triples takes a pair of integer triples (that is, two tuples of three integers each) and computes their element-wise sum. The result is a tuple with three integers. The second function scale_triple takes a triple of three integers and a floating point value and performs element-wise multiplication on the triple and then converts the components to integers using int. It also returns a tuple of three integers.

Notice that the inputs and outputs are not described as RGB values. Youll see later that there is value in having more general functions.

Here are some sample uses of these functions:

In [7]: hw5.add_triples((0, 0, 0), (5, 6, 7)) Out[7]: (5, 6, 7) In [8]: hw5.add_triples((255, 100, 0), (255, 200, 100)) Out[8]: (510, 300, 100) In [9]: hw5.scale_triple((510, 300, 100), 0.5) Out[9]: (255, 150, 50) 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!