Python self-learning code