assuming you are using a module such as pymongo you can do the following. I'm sure there are multiple ways to do this.
from pymongo import MongoClient
mongoConn=MongoClient("mongodb://"+username+":"+password+"@<instancename>:27017")
db="<dbName>"
collection="<collection name>"
query={"Name":"XXX"}
result=mongoConn[db][collection].find_one(query)
print(result)
Then using $set you can update the value.
result['Subject']['history']=80
updates={ "$set": result['Subject']}
mongoConn[db][collection].update_one(query,updates)
result=mongoConn[db][collection].find_one(query)
print(result)
This should update {"Name": "XXX", "Age": 10, "Class": "ABC", "Course":{"Chemistry":100,"Math":90}}
To{"Name": "XXX", "Age": 10, "Class": "ABC", "Course":{"Chemistry":100,"Math":90,'history':80}}
The above is not the most efficient way of doing this as you are writing the subdocument again to the db, but you can use $addToSet as mentioned in below answer to make a more specific change.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…