1answer.
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]
3 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]3 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
Robyn needs to ensure that a command she frequently uses is added to the Quick Access toolbar. This command is not found in the
Semenov [28]

Answer: Access Quick Access commands using the More button

Explanation:

In order for Robyn to ensure that a command she frequently uses is added to the Quick Access toolbar, then she needs to Access Quick Access commands using the More button.

This can be done by clicking on Customize Quick Access Toolbar. Then, Robyn will then click More Commands then he'll click on file tab in the Choose commands from the list. The command will then be chosen and then click on Ok and it'll be added.

7 0
3 years ago
Comment if u wanna text me on behance
kow [346]

Answer:

what is behance? :)

Explanation:

4 0
3 years ago
Which of the following is applicable during a hostile act:
Elanso [62]
Your question has been up too long, a moderator may have to delete it.
we will contact moderators to find your question and remove it, and hopefully, they will refund the points, which is not up to me.
<span>thank you for using brainly.</span>
3 0
3 years ago
Which drugs are known to distort the perception of reality and thought processes
andrey2020 [161]
<span>The correct answer here is Hallucinogen.

Technically all drugs one way or another distort the perception of reality and thought processes but hallucinogens are especially potent in that regard. Hallucinogens are those agents that can cause, among other things, hallucinations and changes in consciousness, emotions and thoughts. LSD is maybe the most known representative of the hallucinogens. </span>
7 0
3 years ago
The use of public wireless connections can increase a user's vulnerability to monitoring and compromise. ____________ software c
GalinKa [24]

The use of public wireless connections can increase a user's vulnerability to monitoring and compromise. <u>VPN </u> software can be used to encrypt transmissions over public networks, making it more difficult for a user's PC to be penetrated.

Explanation:

  • A VPN, or Virtual Private Network, allows you to create a secure connection to another network over the Internet.
  • VPNs can be used to access region-restricted websites, shield your browsing activity from prying eyes on public Wi-Fi, and more. .
  • Virtual Private Network, is a private network that encrypts and transmits data while it travels from one place to another on the internet. VPNs aren't just for desktops or laptops, you can set up a VPN on your iPhone, iPad or Android phone.
  • A VPN encrypts the traffic from your machine to the exit point of the VPN network. A VPN isn't therefore likely to protect you from an adversary like Anonymous.
  • VPNs add another layer of encryption to your internet traffic, your latency will go up and speeds will go down.

3 0
4 years ago
Other questions:
  • If a pilot is converting standard time to UTC time and is given the time 1730 UTC, what would EST be?
    8·2 answers
  • In windows xp, which control panel icon should you choose if you would like to customize your system for left-handed use?
    7·2 answers
  • Your search google for recipe for tonight dinner is an.example of ?​
    8·2 answers
  • Which describes the first step a crawler-based search engine uses to find information?
    10·2 answers
  • HELP ILL MARK BRAINLIETS!! What kind of statement is used to determine which path a program will take? priority statement
    8·2 answers
  • which feature of organisations to manage needs to know about to build and use information system successfully
    6·1 answer
  • 3.6 Code Practice on Edhesive
    10·1 answer
  • If you forget your privacy password what will you do if the ask this question what is the name of one of your teacher?​
    12·1 answer
  • 4.7 code practice question 2 edhesive i cant figure out the code for this problem csn anyone help me?
    5·1 answer
  • How to write my name in binary code ? Rivas
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!