Computer Science, asked by akshaybabuvk, 11 months ago

We want to add a function sum() to the class Node that implements user defined lists of numbers which will compute the sum of the values in a list. An incomplete implementation of sum() given below. You have to provide an expression to put in place of *** on the last line. You may assume that the quantities stored in Node.value can be added using the operator +.

Answers

Answered by siddhartharao77
0

Answer:

we are adding the function sum() to the class node that implements user defined lists of numbers which will compute the sum of the values in a list.

We have to provide an expression to put in place of *** on the last line.

Code:

def sum(self)

if self.value == None:

return(0)

elif self.next == None:

return(self.value)

else:

return(***)

Exact output:

def sum(self)

if self.value == None:

return (0)

elif self.next == None:

return(self.value)

else:

return 0

Explanation:

In python, return 0 indicates the compiler of a successful termination of your program.

Hope it helps!

Similar questions