Respuesta :
Answer:
def sum_numbers(value_list):
total = 0
for n in value_list:
if type(n) == int or type(n) == float:
total += n
return total
Explanation:
Create a function called sum_numbers that takes one parameter, value_list
Initialize the total as 0
Create a for loop that iterates through the value_list
Inside the loop, check the type of the elements. If they are either int or float, add them to total.
When the loop is done, return the total
The Python program code to calculate the addition of the list values by using the method that is "Sum" can be defined as follows:
Program:
def Sum(value_list):#defining a method Sum that takes value_list as a list in parameter
s = 0#defining s variable that initilizes with 0
for n in value_list:#defining a for loop that adds list values
if type(n) == int or type(n) == float:#defining if block that check list value and adds list value in s variable
s += n#addining list value and holds its value in s variable
return s#return s variable value
value_list=[20,-10,30,-9,55.90,70.50,-60,0]#defining a list value_list that holds value
print(Sum(value_list))#calling method and prints its sum value
Output:
please find the attached file.
Program Explanation:
- Defining the method "Sum" that takes a list "value_list" inside the parameters.
- Inside the method, an integer variable "s", and a for loop is declared.
- Inside the loop, it uses the list value and adds its value to the "s" variable, and returns its value.
- Outside the method, a list is defined that holds a value and passes into the method, and prints its return value.
Find out more about the list here:
brainly.com/question/17019263