Ask Question
15 February, 01:45

python Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max.

+1
Answers (1)
  1. 15 February, 02:35
    0
    The following are the program in the Python Programming Language.

    #get input from the user

    val = input ("Enter the value: ")

    #split the input values

    x=val. split ()

    #declare and initialize two variables to 0

    total, l = 0,0

    #set for loop

    for n in x:

    #coverting into string

    n = int (n)

    #perform addition

    total = total + n

    #check that is l is none or n is greater than l

    if (l is None or n > l):

    #initialize the value of n in l

    l = n

    #print the following output

    print ("Average and maximum value are:", total / / len (x), l)

    Output:

    Enter the value: 10 20 0 5

    Average and maximum value are: 8 20

    Explanation:

    Following are the description of the program.

    Firstly, declare a variable 'val' in which we get string type input from the user. Again declare two variables and assigned them to 0. Then set the for loop statement, in which we convert the string variable into the integer and perform addition with those converted values. Set the if conditional statement to check that if the variable 'l' is none or 'n' is greater than 'l ' then, assigned the value of the variable 'n' in the variable 'l'. Finally, print the following result with message.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “python Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers