Ask Question
12 October, 22:30

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

+2
Answers (1)
  1. 13 October, 01:22
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers