The error message 'int' object is not callable indicates an attempt to use an integer object as a callable function. It usually occurs when using function call syntax, but in fact function call syntax should not be used here.
for id in studentid.keys():
print(id+','+studentid[id],end='')
score=studentscore[id]
sum=0
cnt=0
for name in coursename:
print(','+score[name],end='')
sum+=int(score[name])
cnt+=1
print(','+str(int(sum/cnt)))
Python={
"Jhon":78,'张三':80}
OOP={
"Jhon":82,'张三':80}
军事学={
"Jhon":90,'张三':80}
微积分={
"Jhon":83,'张三':80}
s=(sum(Python.values())/len(Python),sum(OOP.values())/len(OOP),sum(军事学.values())/len(军事学),sum(微积分.values())/len(微积分))
print(s)
In this code, sum is used as both an integer variable and a sum summation function. The two conflict.
Solution: Change the name of the sum integer variable above to add_sum.
for id in studentid.keys():
print(id+','+studentid[id],end='')
score=studentscore[id]
add_sum=0
cnt=0
for name in coursename:
print(','+score[name],end='')
add_sum+=int(score[name])
cnt+=1
print(','+str(int(add_sum/cnt)))
Python={
"Jhon":78,'张三':80}
OOP={
"Jhon":82,'张三':80}
军事学={
"Jhon":90,'张三':80}
微积分={
"Jhon":83,'张三':80}
s=(sum(Python.values())/len(Python),sum(OOP.values())/len(OOP),sum(军事学.values())/len(军事学),sum(微积分.values())/len(微积分))
print(s)