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
What sort of technique would you use to sort 10,000 items using just 1000 available slot in your RAM?
beks73 [17]

Answer:

d. Merge sort

Explanation:

Merge sort is example of an efficient sorting alogrithm. The Divide and conquer rule is used in this technique. This method breakdown the list into multiple sublists and each sublist contains a single element. This technique merged in the form of sorted lists. This technique uses external memory of the system while sorting.

Merge sort is used to sort the 10,000 items using only 1,000 slots available in the RAM.

5 0
3 years ago
Write one DDL statement to add a new table Project into exam1. It contains the followingthree columns:-ProjNum of char(3) type,
Goryan [66]

Answer:

Check the explanation

Explanation:

When it comes to database management systems, a query is whichever command that is used in the retrieval of data from a table. In a Structured Query Language (SQL), generally queries are more or less always made by using the SELECT statement.

I have been trying to type it here but it's not working

so kindly check the code in the attached image below

8 0
3 years ago
How can I use the internet/social media to protect my identity?
sattari [20]
Don't show your face and don't put your name or location online? i'm confused by this question.
3 0
3 years ago
Define the following:-<br><br>1) cryptography<br><br>2) Quantum Cryptography​
Readme [11.4K]
1.) the art of writing or solving codes.
2.) the science of exploiting quantum mechanical properties to perform cryptographic tasks.

hope this helps :)
8 0
3 years ago
Read 2 more answers
Compared to using a command line, an advantage to using an operating system that employs a gui is ________.
artcher [175]

Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

<h3>What is operating system?</h3>

An operating system (OS) exists as the program that, after being initially loaded into the computer by a boot program, contains all of the other application programs on a computer. The application programs create use of the operating system by completing requests for services through a specified application program interface (API).

A GUI utilizes windows, icons, and menus to carry out commands, such as opening, deleting, and moving files. Although a GUI operating system is especially navigated using a mouse, a keyboard can also be utilized via keyboard shortcuts or arrow keys.

The GUI, a graphical user interface, exists as a form of user interface that permits users to interact with electronic devices via graphical icons and audio indicators such as primary notation, instead of text-based UIs, typed command labels, or text navigation.

Hence, Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

To learn more about operating system refer to:

brainly.com/question/22811693

#SPJ4

7 0
2 years ago
Other questions:
  • Where should fire extinguishers be stored on a boat?
    7·1 answer
  • You receive a file named Project4.xlsx as an attachment to an email message. What do you expect the file to contain?
    8·1 answer
  • Which of the following is NOT a search engine ( Bing, Yahoo, Ask, Twitter)
    6·2 answers
  • How does machine learning help to make modern Web Application Firewalls more effective? (Choose two.)
    5·1 answer
  • we studied FIFO, Priority, Round Robin (RR), and Weighted Fair Queueing (WFQ) packet scheduling disciplines. Which of these queu
    12·1 answer
  • Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
    13·1 answer
  • Although you are not a full administrator, you are asked to manage a protected document, allowing customized access to any inter
    7·1 answer
  • Guys I need help I cant download anything in the app store I restarted my phone and I know it's not the space on my phone I have
    13·1 answer
  • Which programming languages are the best choices for desktop applications? Select 3 options.
    8·2 answers
  • What is primary difference between the header section of a document and the body
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!