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
amm1812
3 years ago
14

Write a function called average() that takes a single parameter, a list of numeric values. The function should return the averag

e of the values in the list. If the list is empty, average() should return 0.
>>>lst = [1,3,4]

>>>average(lst)

2.6666666666666665

>>>average([])

0
Computers and Technology
1 answer:
QveST [7]3 years ago
3 0

Answer:

The following code is in python.

import statistics as st #importing statistics which include mean function.

def average(lst): #function average.

   return st.mean(lst)#returning mean.

lst=a = list(map(int,input("\nEnter the list : ").strip().split()))#taking input of the list..

print("The average is "+str(average(lst)))#printing the average.

Output:-

Enter the list :

1 2 3 4 5 6

The average is 3.5

Explanation:

I have used the statistics library which includes the mean function that calculates the mean or average of the list.In the function average having lst as an argument returns the mean of the list lst.

Then taking lst input from the user and printing it's average.

You might be interested in
Below you will find the requirements to identify the Account Diversity Grade of a user. Read the requirements carefully and iden
igomit [66]

The technique I used to test the requirement is equivalence partitioning.

<h3>Equivalence Partitioning-</h3>

Generic test data is considered where all the test data satisfies the conditions provided in the problem. Such that,

- ADGrade A --> TA=25 LC=5

- ADGrade B --> TA=20, LC=3

- ADGrade C --> TA=8 LC=2

- ADGrade D --> TA=2, LC=1

- ADGrade null (n/a)—> TA=0, LC=0

Where:

  • TA represents totalAccounts,
  • LC represents loanTypeCount,
  • ADGrade represents accountDiversityGrade

If we are to combine the test data collected above, we would obtain the entire set of test data.

With this in mind, the minimum number of users that are required for testing the requirement is 5.

Read more about requirement testing here:

brainly.com/question/16147055

#SPJ1

8 0
1 year ago
How does the computer help me with school work
Alex73 [517]
You are able to mark your answers on tests and save your work, while on paper, you get it taken away from you.
7 0
2 years ago
Read 2 more answers
A food web is shown below. In this food web, energy is transferred directly from the to the
Irina18 [472]

That answer would be the producer

8 0
3 years ago
A power supply unit for a computer converts:
Vinvika [58]
A power supply unit (or PSU) converts mains AC to low-voltage regulated DCpower for the internal components of acomputer. ... Some power supplies have a manual switch for selecting input voltage, while others automatically adapt to the mains voltage.
5 0
3 years ago
This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.1. do-while
Luba_88 [7]

Answer:

Option 3 is the correct answer.

Explanation:

  • In c, c++ or Java programming language, The for loop takes three parameters in which first is an initialization, second is condition check and the third is an increment. None of the other loop (except for loop) takes three parameters. The other loop takes only one parameter and that is the condition check.
  • So when a user knows about the times of iteration then it is a good choice to use the for loop but when the person does not know about the times of iteration if the loop. It means the iteration of the loop is based on the condition then it is a good choice to chose while or Do-while loop.
  • The above question wants to ask which loop for a user can best if he familiar with the iteration of the loop then the answer is for loop which is started from option 3. Hence Option 3 is the correct answer while the other is not because--
  1. Option 1 states about the do-while loop which takes condition only.
  2. Option 2 states about the while loop which also takes condition only.
  3. Option 4 states about the infinite loop which is not any loop.
  4. Option 5 states about none of these which is not correct because option 3 is the correct answer.

6 0
3 years ago
Other questions:
  • You are troubleshooting a network issue on a client computer and discover that the network card has an IP address of 169.254.196
    6·1 answer
  • Which of the following is true of property?
    13·1 answer
  • A type of touch screen that can be up to four feet by six feet is a(n) _____. plasma screen multitouch interface Electronic Pape
    10·2 answers
  • Given a floating point variable fraction, write a statement that displays the value of fraction on the screen. Do not display an
    13·1 answer
  • When naming a file you should use the _____________ instead of a space in a filename.
    6·1 answer
  • Fill in the correct formula called a contains numbers from Rhodes 1 to 20 you can use the formula blank to find the volume of th
    14·1 answer
  • Data types influence the following in the workflow: (Select all that apply)a. the color choices and layout decisions around comp
    15·2 answers
  • Your disaster recovery plan calls for tape backups stored at a different location. The location is a safe deposit box at the loc
    13·1 answer
  • What are the four steps for planning a table?​
    10·1 answer
  • Cyber vulnerabilities to dod systems may include
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!