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
When setting quotas for disk space, what are the two tools for enabling and configuring quotas? and which of the two are the mor
lora16 [44]
NTFS quotas
File server resource manager.

A system admin has rights to set NTFS quotas if he or she is concerned with some users monopolizing a small amount of disk space. Activating NTFS quotas helps set a storage limit for users using a particular volume. Out of the two, file server resource manager is the most effective and flexible. It is best recommended to use file server resource manager if you need quotas. It comes with file-type filtering and includes folder-level quotas.
8 0
3 years ago
Two different names that refer to the same data item best defines:
Nezavi [6.7K]
You could call that a reference or a pointer.
5 0
3 years ago
Five features of any window​
Vesna [10]

Answer:

The features of any windows are

1. Start menu

2. Notification area or task bar

3. Window snipping tools

4. Using Local Area Networks

5. Windows explorer libraries

Explanation:

8 0
3 years ago
______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
natali 33 [55]
NAS - network attached storage
3 0
4 years ago
What department is cyber security
Paul [167]

Answer:

United States Department of Homeland Security

The National Cyber Security Division (NCSD) is a division of the Office of Cyber Security & Communications, within the United States Department of Homeland Security's Cybersecurity and Infrastructure Security Agency.

<em>Give</em><em> </em><em>me</em><em> </em><em>brainliest</em><em> </em>

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which term represents a computational instruction stored in computer memory?
    13·2 answers
  • Your computer running Windows 7 is doing some very strange things with the operating system. You are fairly certain it is not a
    10·1 answer
  • Write a statement that declares a prototype for a function add, which has two int parameters and returns an int .
    13·1 answer
  • : how do network effects help facebook fend off smaller social-networking rivals?
    7·1 answer
  • When workers use techology to work from home or an office center, they are
    7·2 answers
  • If you change the text to bold,you are changing the what?
    9·1 answer
  • match the parts of a project plan listed in Column A to the specific examples given in Column B.Write the letter of your answer
    13·1 answer
  • How to make your nest learning thermostat stop doing something
    14·1 answer
  • I need help ASAP which option is an example of a resource that would most likely become a constraint in building a game
    7·2 answers
  • What sets Web pages apart from other documents is that they contain a special kind of text called ___, which is document text th
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!