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
levacccp [35]
3 years ago
5

In Python,The sum of the elements in a tuple can be recusively calculated as follows:The sum of the elements in a tuple of size

0 is 0Otherwise, the sum is the value of the first element added to the sum of the rest of the elementsWrite a function named sum that accepts a tuple as an argument and returns the sum of the elements in the tuple.
Computers and Technology
1 answer:
andrezito [222]3 years ago
3 0

Answer:

Following are the program in the Python Programming Language.

# Define the function

def Sum(tu):

# Check if the tuple contain 0

 if len(tu)==0:

#Then, Return 0

   return 0

#Otherwise

 else:

#call the recursive function

   return tu[0]+Sum(tu[1:])

#Set tuple type variable

tu=(2,5,1,8,10)

#print and call the function

print("The sum of tuple is:",Sum(tu))

<u>Output:</u>

The sum of tuple is: 26

Explanation:

Here, we define a function "sum()" and pass an argument "tu" which stores the tuple type value, inside the function.

  • Set the if conditional statement to check condition is the length of the tuple is 0 then, return 0.
  • Otherwise, call and return the sum of the tuple which is recursively calculated and close the function.

Finally, set the tuple type variable "tu" and initialize the value in it then, print and call the function sum.

You might be interested in
Question #3
Mnenie [13.5K]

Answer: It can include string data.

It can include bool data.

It can include numeric data.

Explanation:

I’m on this assignment too :) Good luck & correct me if I’m wrong thank you!

4 0
3 years ago
Name the functional arms of MSDE.
fgiga [73]

Answer:

It is aided in these initiatives by its functional arms – National Skill Development Agency (NSDA), National Skill Development Corporation (NSDC), National Skill Development Fund (NSDF) and 33 Sector Skill Councils (SSCs) as well as 187 training partners registered with NSDC.

3 0
3 years ago
categorize each job role as an administrative job or management job auditor director legal secretary payroll clerk etc ​
abruzzese [7]

Explanation:

look after the office jobs

3 0
3 years ago
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
3 years ago
When using color in a computer - generated presentation aids you should use?
Temka [501]
<span>the answer is: the same background color on all visuals and no more than two colors for words.</span>
6 0
3 years ago
Other questions:
  • How has technology affected the way that you produce art like photographs?
    8·1 answer
  • A virus or worm can have a payload that installs a(n) __________ door or trap-door component in a system, which allows the attac
    14·2 answers
  • Which of these describes the functionality of a database? Check all of the boxes that apply.
    10·2 answers
  • А.<br> is the highest education degree available at a community college.
    6·1 answer
  • How to cancel branly subscription??​
    8·1 answer
  • Write any four difference between email and effects​
    14·1 answer
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    9·1 answer
  • When you check your hard drive to see how much space is available, you are checking your
    15·1 answer
  • Which of the following is true about stateless applications?
    9·1 answer
  • Who designed the apple i computer in 1976?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!