1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DENIUS [597]
3 years ago
8

Write a function that will sum all of the numbers in a list, ignoring the non-numbers. The function should takes one parameter:

a list of values (value_list) of various types. The recommended approach for this:
a. create a variable to hold the current sum and initialize it to zero.
b. use a for loop to process each element of the list.
c. test each element to see if it is an integer or a float, and, if so, add its value to the current sum.
d. return the sum at the end.
Computers and Technology
1 answer:
olasank [31]3 years ago
3 0

In python 3.8:

def func(value_list):

   lst = [x for x in value_list if type(x) == int or type(x) == float]

   return sum(lst)

print(func(["h", "w", 32, 342.23, 'j']))

This is one solution using list comprehensions. I prefer this route because the code is concise.

def func(value_list):

   total = 0

   for x in value_list:

       if type(x) == int or type(x) == float:

           total += x

   return total

print(func(["h", "w", 32, 342.23, 'j']))

This is the way as described in your problem.

You might be interested in
•Should other states wait to see if the high-speed rail system works well before starting their own plans for similar systems?
solmaris [256]
Other states should see how well the system works and also understand how much money it requires for the state to build a high-speed rail system.
7 0
3 years ago
Which of these is system software? Check all
Darya [45]

Answer:

Windows OS is software....

6 0
3 years ago
If there is no computer how would human beings have performed the workk
Katena32 [7]

I’m pretty sure we would do things at the agency would do it because overall th i’m pretty sure we would do things at the agency would do it because overall the agents were actually much smarter than we are literally right now and someways because they use more organic and natural and a whole things like herbs Escentuals would help you more than the chemicals in the flu shots that we take and have chemicals and are bad for the body

3 0
3 years ago
PLEASE ANSWER ASAP!!!!
kondaur [170]

Answer:

na bro, esta dificil

Explanation:

3 0
3 years ago
What are some commands found in the Sort dialog box? Check all that apply.
Novosadov [1.4K]

Answer:

A. add level

D. Delete level

E. Copy level

F. Move up or down

Explanation:

I just did it on edg. 2020

4 0
3 years ago
Read 2 more answers
Other questions:
  • ​PeroxyChem's IT staff was able to free its IT staff to spend less time on routine maintenance and more time on strategic tasks
    11·1 answer
  • ________ is used for supervisory messages at the internet protocol layer.
    10·1 answer
  • The software used to help run the computer hardware is the _____.
    15·2 answers
  • When mapping a drive, you can type in the path to the shared folder on the host computer. what is the syntax for the path?
    7·1 answer
  • You can rotate a selected graphic by dragging a ________ rotation handle
    13·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • PLEASE HELP what is the mechanical advantage of a wheel with a radius of 8.0 cm connected with a axle with a radius of 2.5 cm?
    12·2 answers
  • Write a valid HTML + Python page that will count numbered from 1 to 1,000,000?​
    9·1 answer
  • What are the main types of database end users,? Discuss the main activi-ties of each
    10·1 answer
  • Define foreign employment​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!