Using the same data, make a Python coding for ∑XiYi
Data
X = 4 6 8 10 14 16 20 22 24 28
Y = 30 18 22 28 14 22 16 8 20 8
For example:
Test Result
print(XiYi)
[120, 108, 176, 280, 196, 352, 320, 176, 480, 224]
print(sumXiYi)
2432
Using the same data, make a Python coding for ∑XiYi
Data
X = 4 6 8 10 14 16 20 22 24 28
Y = 30 18 22 28 14 22 16 8 20 8
For example:
Test Result
print(XiYi)
[120, 108, 176, 280, 196, 352, 320, 176, 480, 224]
print(sumXiYi)
2432
You can use zip:
X = [4, 6, 8, 10, 14, 16, 20, 22, 24, 28]
Y = [30, 18, 22, 28, 14, 22, 16, 8, 20, 8]
print(sum(x*y for x,y in zip(X,Y)))
Output:
2432