Share Price Volatility please help

Back to Problem Solutions forum

dlardashev     2017-01-16 17:31:42

Help me please. I think I cannot understand this task and what I must do because my English is weak. Here my code:

from statistics import variance 

times = int(input())
result = []

for i in range(times):
    data = input().split(' ')
    name = data.pop(0)
    data = [int(x) for x in data]

    var = variance(data)

    if data[0] < 50:
        waste = (sum(data) / len(data) * 0.02)
    else:
        waste = (sum(data) / len(data) * 0.08)

    if waste <= var:
        result.append(name)

print (' '.join(result))

I always get 1 or 2 wrong answer. What am I not understanding in this task?

Quandray     2017-01-16 20:46:05
User avatar

I don't know if this will explain it, but make sure you are calculating the stddev the way specified in the link from the problem description.

http://www.calculator.net/standard-deviation-calculator.html shows two ways of calculating stddev and I can't tell, from your code, which one you are using.

Please login and solve 5 problems to be able to post at forum