JanessaTheGreat8304 JanessaTheGreat8304
  • 25-11-2019
  • Computers and Technology
contestada

Write the definition of a function named sum_list that has one parameter, a list whose elements are of type int. The function returns the sum of the elements of the list as an int.

Respuesta :

codiepienagoya codiepienagoya
  • 26-11-2019

Answer:

The code to the given question can be given as:

Code:

def sum_list(a):    #define function.

   return sum(a)  # return sum of elements.

Explanation:

In the above python programming language code firstly we define a function that is "sum_list()" to define any function we use the def keyword.

In this function, we pass one parameter that is "a" add all elements in the list. To add this number we use the sum function it is the inbuilt function that returns the sum of the elements of the list as an int.

Answer Link

Otras preguntas

IN THE 1900 HOW WERE THE US SENATE CHOSEN
Please help me answer this question
The product of two consecutive multiples of 5 is 500.what are these numbers?
is 0.31 greater or less than 0.13
n+6=8n+6-6=8-__n=__I am having problems solving this problem....can you help
Suppose you earn $7.25 per hour working part-time for a florist. Write and solve an inequality to find how many full hours you must work to earn at least $125.
A number is such that its ten digit is twice its unit digit. Prove that the number itself must be seven times the sum of its digit
What is -3,1,-5,3,-1 from least to greatest?
Which statement is true?  A.|–8|< |8|  B.|–2| > 1  C.|–7| = –7  D.|12| > |–15|
Victor pays $1200 rent. If his monthly salary is $3800, what percent of his monthly salary is his rent? Round to the nearest tenth of a percent.