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 a specific challenge faced by information visualization researchers who are building an interface?
Mkey [24]

Answer:

 Information virtualization is the process of representing the abstract data such as numeral number and text into the form of visual which is human can easily understand.

The main challenges faced by the information visualization researchers are:

  • The main challenge which are faced by the information virtualization is during the data importing and also cleaning in the system.
  • It also not able to access the large amount of the data easily from the system.
  • Due to the poor selection of the scale and the coordinate rotation it also lead to the data distortion.
3 0
3 years ago
Where is voice data stored in Android?
Dafna1 [17]
Inside its internal hard-drive and your google account!
8 0
3 years ago
ANSWER ASAP, I'LL MARK THE BRAINLIEST
Travka [436]

Answer:

Push to make switch

Explanation:

The sound is created after you push it. Pushing it is the input and the sound is the output

4 0
2 years ago
Write a program that prompts the user for an integer, then asks the user to enter that many values. Store these values in an arr
Svetllana [295]

Answer:

//The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

//The class Solution is defined

public class Solution {

   //The main method is defined here and signify the beginning of program execution

   public static void main(String args[]) {

       

       //Scanner object 'scan' is created to receive user input

       Scanner scan = new Scanner(System.in);

       //Prompt display to the user to enter size of array

       System.out.print("Enter the range of array: ");

       //User input is assigned to arraySize

       int arraySize = scan.nextInt();

       //userArray is initialized with arraySize as its size

       int[] userArray = new int[arraySize];

       

       //counter to count number of array element

       int count = 0;

       //while loop which continue executing till the user finish entering the array element

       while (count < arraySize){

           System.out.print("Enter each element of the array: ");

           userArray[count] = scan.nextInt();

           count++;

       }

       

       //A blank line is printed for clarity

       System.out.println();

       

       //for loop to print each element of the array on straight line

       for(int i =0; i <userArray.length; i++){

           System.out.print(userArray[i] + " ");

       }

       

       //A blank line is printed for clarity

       System.out.println();

       

       //for loop is use to reverse the array in-place

       for(int i=0; i<userArray.length/2; i++){

           int temp = userArray[i];

           userArray[i] = userArray[userArray.length -i -1];

           userArray[userArray.length -i -1] = temp;

       }

       

       //for loop to print each element of the reversed array on straight line

       for(int i =0; i <userArray.length; i++){

           System.out.print(userArray[i] + " ");

       }

     

   }

}

Explanation:

The program is commented to give detailed explanation.

The for-loop use in reversing the array works by first dividing the array into two half and exchanging the first half elements with the second half elements. The element from the first half is assigned to temp variable on each loop, then the element is replaced with the equivalent element from the second half. And the element from the second half is replaced with the value of temp.

3 0
3 years ago
A single inheritance model means: * A) A class can only have one parent class (superclass) B) A class can only have one child cl
Troyanec [42]

Answer:

The answer is A)

Explanation:

In programming languages like java you can only use single inhertance meaning a class can only inherit attributes from one class. But in other languanges like C you can have multiple inhertance

6 0
3 years ago
Other questions:
  • You're working at a large industrial plant and notice a tag similar to the one shown in the figure above. Which of the following
    5·1 answer
  • Suppose you want to delete an existing file from within Word. What would you do? A. Click on the File button, choose Recent, ope
    9·1 answer
  • After a conditional formatting rule is created using the ____ dialog box, the rule is then available for use in the database fro
    11·1 answer
  • A collection of information stored in an electronic format that can be searched by a computer.
    14·1 answer
  • You have just changed the system time within your computer's BIOS. You choose to save the settings upon exit. What happens next
    14·2 answers
  • Help me out with this .....
    10·1 answer
  • My question is do you learn how to do a voice over in technology?
    14·1 answer
  • What is a characteristic of the network layer in the OSI model allows carrying packets for multiple types of communications amon
    9·1 answer
  • The purpose of​ a/an _________ system is to capture best practice solutions and program them into a set of rules in a software p
    13·1 answer
  • Describe how you will lunch a web browser using the start menu​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!