Control variables, as you may know, are factors that the researcher is not interested in examining but believes have a substantial impact on the value that your dependent variable takes. When conducting experiments, or gathering data, people usually keep the value of this variable constant.
Assume you're trying to model a person's health status, i.e., determine whether he's healthy or not, and you're using age, gender, and his/her activity routine as inputs to your model, and you want to see how each input influences your target variable. However, as you are well aware, the country in which the individual resides has an impact on his health (which encodes the climate, heath facility etc.). So, to ensure that this variable (country) has no bearing on your model, you must collect all of your data from a single country.
So, in response to your first question, no, Python does not provide controlled variables. It just assumes that the experimenter is interested in all of the input variables you're sending in.
In response to your second question, one method of dealing with control variables is to first group the data with respect to it, so that each group now has a constant value for that control variable. We then run Logistic regression or any model separately for each group, and then 'pool' the results from different models. However, if the number of levels in your control variable is really large, we must treat it as an independent variable and feed it into our model.
Ignite Your Future with Machine Learning Training!