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
What is included in a linked list node?
il63 [147K]

Answer: I a reference to the next node

III a data element

Explanation:

A linked list is simply referred to as a linear data structure, whereby the elements would not be stored at memory locations that are together in the sequence.

In simple words, we can simply say that a linked list is made up of nodes in which, every node has a data element and also a link or reference to the next node that is in the list.

Therefore, based on the explanation above, the correct option will be:

I. a reference to the next node

III a data element

7 0
3 years ago
What is the function of Cascading Style Sheets?
Kaylis [27]

Answer:

answer is c

Explanation:

no need for explaination

8 0
3 years ago
Given a member function named set_age() with a parameter named age in a class named Employee, what code would you use within the
BaLLatris [955]

Answer:

Explanation:

This would be considered a setter method. In most languages the parameter of the setter method is the same as the variable that we are passing the value to. Therefore, within the function you need to call the instance variable and make it equal to the parameter being passed. It seems that from the function name this is being written in python. Therefore, the following python code will show you an example of the Employee class and the set_age() method.

class Employee:

   age = 0

   

   def __init__(self):

       pass

   

   def set_age(self, age):

       self.age = age

As you can see in the above code the instance age variable is targeted using the self keyword in Python and is passed the parameter age to the instance variable.        

6 0
2 years ago
How to convert binary number into decimal number​
Alecsey [184]

Answer:

Multiplying by 2

Explanation:

The binary num number to decimal conversion is made by making the sum of each binary digits multiplying by 2 with raised to the power of the positional notation of digits .

Hope it is helpful to you

6 0
2 years ago
Read 2 more answers
What do you ensure when you set up goals and objectives for your website design?
fredd [130]

Answer:

a

Explanation:

You know that if you searched brianly for the answer some one else has already answered the same question jut trynna help some one out to help save your points

7 0
3 years ago
Other questions:
  • Remember that the function "main" takes optional parameters, these being common:
    10·1 answer
  • 52.
    11·1 answer
  • To increase the view of a document on the screen, use the _____. View icon Zoom slider full-screen reading boldface font
    9·1 answer
  • Monica is teaching herself to paint. What web resource would be the most helpful
    14·1 answer
  • Match the metric units with these measurements
    8·1 answer
  • Que es un programa de ordenador?
    10·1 answer
  • A simulation system is a technology that enables you to take over a customer’s screen, mouse, or other connected device in order
    13·1 answer
  • Function of pons for class 7​
    15·1 answer
  • Set of general format used to write program in any programming language?​
    10·1 answer
  • A piece of data in a program whose value can change is called a(n) -
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!