<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_com(self, first=0, last=None):
 """ Returns the center of momentum for all particles in the simulation. Parameters first: int, optional If ``first`` is specified, only calculate the center of momentum starting from index=``first``. last : int or None, optional If ``last`` is specified only calculate the center of momentum up to (but excluding) index=``last``. Same behavior as Python's range function. Examples -------- 0.0 5.0 """

        if last is None:
            last = self.N_real
        clibrebound.reb_get_com_range.restype = Particle
        return clibrebound.reb_get_com_range(byref(self), c_int(first), c_int(last))