Question

in coral. Statistics are often calculated with varying amounts of input data. Write a program that...

in coral. Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: When the input is 15 20 0 5 -1, the output is: 10 20 You can assume that at least one non-negative integer is input.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
s = input()
lst = [int(x) for x in s.split(" ")]
total = 0
maxValue = None
length = 0
for x in lst[:-1]:
    total += x
    if(maxValue==None):
        maxValue = x
    elif(maxValue < x):
        maxValue = x
    length += 1
print((total//length),maxValue)

Note: This is python code

Add a comment
Know the answer?
Add Answer to:
in coral. Statistics are often calculated with varying amounts of input data. Write a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT