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 output? c = 1 sum = 0 while (c < 10): c = c + 3 sum = sum + c print (sum)
Valentin [98]

Answer:

21

Explanation:

The values of c that make it into the loop are 1, 4, 7.

The values that are added to sum are 3 higher, i.e., 4,7 and 10.

The sum of those is 21.

p.s. why did you not run the program yourself?

3 0
3 years ago
Witch is the correct description of the first act in a classical game story structure
3241004551 [841]
Hitler because,Hitler was a great and wealthy companion
4 0
4 years ago
How many bits strings of length 12 contain (8 pts)? a. exactly three 1s? b. at most three 1s? c. at least three 1s? d. an equal
Irina-Kira [14]

1. Exactly three 1 s?

$$\left(\begin{array}{c}12 \\3\end{array}\right)=220$$

2. At most three$1 \mathrm{~s}$ ?

$$\left(\begin{array}{c}12 \\0\end{array}\right)+\left(\begin{array}{c}12 \\1\end{array}\right)+\left(\begin{array}{c}12 \\2\end{array}\right)+\left(\begin{array}{c}12 \\3\end{array}\right)=1+12+66+220=299 \text {. }$$

3. At least three 1 s?

Take a shortcut by using the previous answer:$2^{12}-66-12-1=4017$

4. An equal number of$0 \mathrm{~s}$ and $1 \mathrm{~s}$ ?

$$\left(\begin{array}{c}12 \\6\end{array}\right)=924$$

<h3>What is strings ?</h3>

The C programming language includes a set of functions executing operations on strings in its standard library. Different operations, such as copying, concatenation, tokenization, and searching are supported.

In C programming, a string exists as a sequence of characters terminated with a null character \0. For example char c[] = "c string"; When the compiler discovers a sequence of characters enclosed in the double quotation marks, it appends a null character \0 at the end by default. The C language does not have a distinctive "String" data type, the way some other languages such as C++ and Java do. Instead, C stores strings of characters as arrays of chars, completed by a null byte.

1. Exactly three 1 s?

$$\left(\begin{array}{c}12 \\3\end{array}\right)=220$$

2. At most three$1 \mathrm{~s}$ ?

$$\left(\begin{array}{c}12 \\0\end{array}\right)+\left(\begin{array}{c}12 \\1\end{array}\right)+\left(\begin{array}{c}12 \\2\end{array}\right)+\left(\begin{array}{c}12 \\3\end{array}\right)=1+12+66+220=299 \text {. }$$

3. At least three 1 s?

Take a shortcut by using the previous answer:$2^{12}-66-12-1=4017$

4. An equal number of$0 \mathrm{~s}$ and $1 \mathrm{~s}$ ?

$$\left(\begin{array}{c}12 \\6\end{array}\right)=924$$

To learn more about strings refer to:

brainly.com/question/27251062

#SPJ4

3 0
2 years ago
the block cipher attack technique that attempts to retrieve the key by performing decryption and encryption simultaneously on a
tankabanditka [31]

The block cipher attack strategy that attempts to retrieve the key by performing decryption and encryption simultaneously on a understood plaintext-ciphertext pair exists plaintext attack.

<h3>What is plaintext attack?</h3>

The known-plaintext attack is a type of cryptanalysis attack in which the attacker has access to both the encrypted and plaintext versions of the target data. These can be used to reveal additional hidden information, including code books and secret keys. An attack using known plaintext occurs when the attacker has access to pairs of known plaintexts and the ciphertexts that go with them.

The objective is to figure out the secret key (or keys) or to create an algorithm that would enable him to decrypt any additional messages. Ordinary readable text before it is converted into ciphertext in cryptography is known as plaintext, as is readable text that has been recovered from encryption. Not all data inputted into or outputted by encryption methods is plaintext.

Hence,  The block cipher attack strategy that attempts to retrieve the key by performing decryption and encryption simultaneously on a understood plaintext-ciphertext pair exists plaintext attack.

To learn more about cryptanalysis attack refer to:

brainly.com/question/19202523

#SPJ4

3 0
1 year ago
Which of the following cannot be performed from the windows task manager?
liraira [26]
I think C..
hoep i help

5 0
4 years ago
Read 2 more answers
Other questions:
  • How do solar system and galaxies differ?
    9·1 answer
  • The arrow next to all programs indicates
    13·1 answer
  • SOMEONE HELP PLEASE!!!!!
    6·1 answer
  • Can someone help me
    12·2 answers
  • Green field country is planning to conduct a cricket match between two teams A and B. a large crowd is expected in the stadium a
    6·1 answer
  • Google Slides is most similar to which of the following programs?
    10·2 answers
  • Which type of protocol allows for a secure data transmission using encryption methods?
    7·1 answer
  • (Giving brainliest to best answer, don't make an answer if you don't know or its jumble)
    11·2 answers
  • what stage is the most inner part of the web architecture where data such as, customer names, address, account numbers, and cred
    11·1 answer
  • Please answer........
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!