How to calculate Gene Ontology terms in python
You can calculate gene ontology similarity with the GOSemSim R package (paper)(disclaimer I'm a contributor to this package). You have several similarity scores implemented, some of them are across the three subontologies.

In python you have the GOATOOLS (paper). I think there was another Python package but now I don't remember its name.