answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elanso [62]
2 years ago
7

Write a function called add_tuples that takes three tuples, each with two values, and returns a single tuple with two values con

taining the sum of the values in the tuples. Test your function with the following calls:
print(add_tuples( (1,4), (8,3), (14,0) ))
print(add_tuples( (3,2), (11,1), (-2,6) ))
Note that these two lines of code should be at the bottom of your program. This should output

(23, 7)
(12, 9)

this is my output but I keep getting errors;
def add_tuples(tup):
add1= tup[0][0]+ tup[1][0] +tup[2][0]
add2= tup[0][1]+ tup[1][1] + tup[2][1]
return add1, add2
print(add_tuples( (1,4), (8,3), (14,0) ))
print(add_tuples( (3,2), (11,1), (-2,6) ))
Computers and Technology
1 answer:
Leni [432]2 years ago
4 0

In Python, tuples are indeed a data structure that also stores an ordered sequence of unchanging values, and following are the Python program to the given question:

Program Explanation:

  • Defining a method "add_tuples" that takes three variables "firstTuple, secondTuple, thirdTuple" into the parameter.
  • After accepting the parameter value a return keyword is used that adds a <em><u>single tuple with two values</u></em> and returns its value into the form of (x,y).
  • Outside the method, two print method is declared that calls the above method by passing value into its parameters.

Program:

def add_tuples(firstTuple, secondTuple, thirdTuple):#defining a method add_tuples that takes three variable in parameters

   return firstTuple[0]+secondTuple[0]+thirdTuple[0],firstTuple[1]+secondTuple[1]+thirdTuple[1] #using return keyword to add value

print(add_tuples((1,4), (8,3), (14,0)))#defining print method that calls add_tuples method takes value in parameters

print(add_tuples((3,2), (11,1), (-2,6)))#defining print method that calls add_tuples method takes value in parameters    

Output:

Please find the attached file.  

Learn more:

brainly.com/question/17079721

You might be interested in
A reputable, world-renowned auction house uses blockchain to verify the authenticity of paintings prior to placing them up for s
REY [17]

Answer:

The ledgers are secure, shared, and incorruptible is the correct answer.

6 0
2 years ago
3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?
Charra [1.4K]

Answer:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

Explanation:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

7 0
2 years ago
c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
Lilit [14]

The below code will help you to solve the given problem and you can execute and cross verify with sample input and output.

#include<stdio.h>

#include<string.h>

 int* uniqueValue(int input1,int input2[])

 {

   int left, current;

   static int arr[4] = {0};

   int i      = 0;

     for(i=0;i<input1;i++)

      {

         current = input2[i];

         left    = 0;

         if(current > 0)

         left    = arr[(current-1)];

      if(left == 0 && arr[current] == 0)

       {

       arr[current] = input1-current;

       }

       else

   {

       for(int j=(i+1);j<input1;j++)

       {

           if(arr[j] == 0)

           {

               left = arr[(j-1)];

               arr[j] = left - 1;

           }

       }

   }

}

return arr;

}

4 0
2 years ago
Exponentiation Is a/an operater?​
garik1379 [7]

Answer:

Yes it is

Hope this helps

5 0
1 year ago
When you check to see how much RAM, or temporary storage you have available, you are checking your _____.
victus00 [196]

Answer: primary memory

5 0
2 years ago
Other questions:
  • What critical issue in symmetric and asymmetric encryption is resolved by using a hybrid method like diffie-hellman?
    5·2 answers
  • Let's assume that the smallest possible message is 64 bytes (including the 33-byte overhead). if we use 100base-t, how long (in
    10·1 answer
  • An mp3 takes up about 16 kilobytes of memory per second of music. if you owned a one terabyte hard drive and filled it with only
    15·1 answer
  • What is the other name designated to a game master of multiplayer online games (MMOs)?
    11·2 answers
  • Static packet filtering firewalls are limited to ________. inspecting packets for which there are good application proxy filteri
    8·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • Alyosha was explaining to a friend the importance of protecting a cryptographic key from cryptoanalysis. He said that the key sh
    10·1 answer
  • Explain working principle of computer?​
    13·1 answer
  • In this first journal assignment, you will explore the role of testing in the SDLC. You will explain the role and importance of
    9·1 answer
  • Rideshare companies like Uber or Lyft track the x,y coordinates of drivers and customers on a map. If a customer requests a ride
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!