Ask Question

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.

+5
Answers (1)
  1. 27 January, 00:50
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers