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
Which of the following is part of the process of publishing a website?
Mamont248 [21]
I think it's the first one. Hope this helps
6 0
3 years ago
Read 2 more answers
All mortgage companies are willing to loan anyone money regardless of credit scores. True or false?
alina1380 [7]

Your credit reports and scores will be taken into consideration by lenders when deciding whether you qualify for a loan and what interest rate to offer you.You can have problems getting a loan if your credit report contains mistakes.So, check your credit right away.

Should you check your credit score before applying for a mortgage?

  • Although a credit score as low as 500 may be acceptable, there are still a number of other conditions to be met before you can receive an FHA loan guarantee.
  • Mortgage insurance, a 10% down payment (or 3.5% if your credit score is above 580), and a monthly payment are all requirements for these loans.
  • When you apply for a traditional loan, it is advised that your credit score be 620 or above.
  • Lenders may not be able to approve your loan or may be forced to offer you a higher interest rate, which could mean higher monthly payments, if your credit score is below 620.
  • A higher score may make you eligible for lower mortgage interest rates and fees because it gives a lender more assurance that you will make payments on time.
  • If you have a great credit score, some lenders may also lower their down payment requirements.
  • By comparing interest rates and costs from lenders who offer loans made for consumers with weak credit, you can obtain a loan despite having a low credit score.
  • And even better, think about repairing your credit before you apply for a loan so you may get better conditions.

       To learn more about mortgage refer

     brainly.com/question/1318711  

      #SPJ1

7 0
1 year ago
How to set up a paper format in any type of Microsoft version ????
Mashcka [7]
Explain further what you mean by that.
7 0
4 years ago
In the lungs,blood picks up carbon dioxide and releases oxygen true or false
Maksim231197 [3]

Answer:

false

Explanation:

plants do that, they absorb carbon dioxide and then they create oxygen, then humans breathe the oxygen and makes CB

8 0
3 years ago
The internet is an example of
DochEvi [55]
A large multi user program
6 0
3 years ago
Read 2 more answers
Other questions:
  • Qual foi o primeiro computador no mundo a ser criado e qual é a hitória por trás?
    8·1 answer
  • . What is the output of this code sequence?
    8·1 answer
  • The __________ format is a proprietary file format defined by guidance software for use in its forensic tool to store hard drive
    15·1 answer
  • Who can help me on my school we will to google meet and i share my screen
    5·1 answer
  • Which of the following would not be considered a PC?
    13·2 answers
  • A new systems development project is Pete’s first experience as a project manager, and he has led his team successfully to the p
    13·1 answer
  • In a _______ format, the date line and the signature block are centered.
    6·1 answer
  • CAN YOU PLEASE HELP WITH THIS DUE IN 10 MINUTES
    8·1 answer
  • When you get a new sim card do it come with a new number or do you have a activate the phone and get a new number in store ?
    9·1 answer
  • Meteoroids are small space rocks. They are usually pieces of asteroids or comets. Meteoroids orbit the sun like asteroids and co
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!