''Int object not callable'
I am attempting to calculate the variance of my list without using the sum function or other libraries. No matter what I change, I receive 'int object is not callable'. This is what I have so far.
sum2 = 0
total_len = len(class_list)
for i in range(total_len):
the_sum2 = the_sum2 + (class_list[i] - total_mean)**2
var = the_sum2 / len(class_list)
Solution 1:[1]
@Ella you can try like this it will give you solution
import numpy as np
the_sum2 = 0
class_list = [1,2,2,3,4,5]
total_len = len(class_list)
mean = np.mean(class_list)
for i in range(total_len):
the_sum2 = the_sum2 + (class_list[i] - mean)**2
var = the_sum2 / len(class_list)
print(var)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Srini |
