In this paper, a comparative analysis of two stochastic methods of global optimization is carried out: the Particle Swarm Optimization method and the Ant Colony Optimization method. The analysis and evaluation of efficiency were carried out using parameters such as the number of calls to the objective function, the rate of convergence, resources, computational efficiency, sensitivity to parameters, and resistance to initial conditions. The article presents the program codes of these methods in the Python environment, designed to calculate the global extremum of semi-continuous functions from below. Well- known test functions were used to construct (by gluing) semi-continuous functions at different values of input parameters.