Ask Question
11 December, 02:24

Write a function named "sum_values" that takes a list as a parameter and returns the sum of the values at indices 9, 8, and 11. You may assume the input will be large enough to have values at all these indices

+3
Answers (1)
  1. 11 December, 02:34
    0
    def sum_values (mylist):

    sumSomeNumbers = mylist[9]+mylist[8]+mylist[11]

    print (sumSomeNumbers)

    Explanation:

    Using python programming language;

    A function is created called sum_values that accepts one parameter

    Withing the function body, a variable called sumSomeNumbers is created to hold the sum of the elements at index 9,8 and 11

    Finally a print Statement is used to output sumSomeNumbers

    When the function is called It is passed a list as argument and it will display the sum of the three numbers at that indices

    for example:

    lst = [23,3,4,5,6,63,2,3,5,6,5,5,7,89]

    sum_values (lst)

    Outputs 16
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a function named "sum_values" that takes a list as a parameter and returns the sum of the values at indices 9, 8, and 11. You may ...” 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