subject

If you have a list consisting of just numbers, then you can add all of the values in the list using the sum() function.

If your list consists of some numbers and some values of other types (e. g., lists, strings, sets), the sum() function will fail. In this question, we're asking you to write a function that will sum all of the numbers in a list, ignoring the non-numbers. The function below takes one parameter: a list of values (value_list) of various types.

The recommended approach for this:

(1) create a variable to hold the current sum and initialize it to zero,

(2) use a for loop to process each element of the list,

(3) test each element to see if it is an integer or a float, and, if so, add its value to the current sum,

(4) return the sum at the end.

student. py 1

Hef sum_lengths(value_list):

# Implement your function here. Be sure to indent your code block! Restore original file

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
The blank button automatically displays next to the data when you select a range of numeric data which is an available option for creating a chart
Answers: 3
question
Computers and Technology, 23.06.2019 03:10
Acomputer has a two-level cache. suppose that 60% of the memory references hit on the first level cache, 35% hit on the second level, and 5% miss. the access times are 5 nsec, 15 nsec, and 60 nsec, respectively, where the times for the level 2 cache and memory start counting at the moment it is known that they are needed (e.g., a level 2 cache access does not even start until the level 1 cache miss occurs). what is the average access time?
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Why do we mark tlc plates with pencil and not with pen
Answers: 2
You know the right answer?
If you have a list consisting of just numbers, then you can add all of the values in the list using...
Questions
question
Mathematics, 11.06.2020 21:57
question
Mathematics, 11.06.2020 21:57
Questions on the website: 13722363