One of the tasks that you will engage in when learning a new programming languag
ID: 3760236 • Letter: O
Question
One of the tasks that you will engage in when learning a new programming language is locating the name of a built-in function that performs a common, simple operation. While you might be tempted to write your own code that performs this operation, locating a built-in function is usually preferable since the built-in version is automatically correct and others that read your code will immediately recognize what your code is doing. Python has a built-in function that adds up the numbers in a list. For example, given the list [1, 2, 5, 4], this function returns 1 + 2 + 5 + 4 = 12. Use your search skills to find the name of this built-in function. Enter the name of the built-in function below, without any parentheses or arguments. (Note that we could just tell you the name of this function. However, the point of this problem is for you to start learning how to locate useful language features on your own.)
Explanation / Answer
Ans: sum
Explanation:
python has built in function to add all elements of a list.
sum(list) function takes list as argument and returns sum of all elements of the list.
Example: list = [2,3,4,5]
sum(list)
will give result = 14
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.