actually i'm new to learning python and mysql database i have table named TABEL_NILAI in database like this:
id auto_increment primary key
NILAI_TRUST FLOAT
NAMA_ALAT VARCHAR(10)
--------------------------
|ID|NILAI_TRUST|NAMA_ALAT|
--------------------------
|1 | 0.12 | ALAT1 |
--------------------------
|2 | 0.34 | ALAT2 |
--------------------------
|3 | 0.54 | ALAT3 |
--------------------------
So i want to Retrieve value NILAI_TRUST from TABEL_NILAI and i want to do some math. here's code i was made:
kursor = db.cursor()
kursor.execute("SELECT NILAI_TRUST FROM TABEL_NILAI")
hasil = kursor.fetchall()
def hitung_standardeviasi():
#input data
TrustValue= x().split(',')
for i in range(len(TrustValue)):
TrustValue[i]= int(TrustValue[i])
jumlah=0
#Average
for i in range(len(TrustValue))
jumlah += TrustValue[i]
ratarata = jumlah/len(TrustValue)
total=0
#sigma
for i in range(len(TrustValue))
hitung = (TrustValue[i]-ratarata)**2
total += hitung
sigma = total/(len(TrustValue)-1)
#standardeviasi
standardeviasi = math.sqrt(sigma)
print(standardeviasi)
for x in hasil:
hitung_standardeviasi()
And giving me error like:
Traceback (most recent call last):
File "/home/lihat_tabel.py", line 60, in <module>
hitung_standardeviasi()
File "/home/lihat_tabel.py", line 24, in hitung_standardiviasi
Trustvalue = x().split(',')
TypeError: 'tuple' object is not callable
so how to retrieve value into python variable in right ways. Please help:(