In C++, this can be achieved by:
std::default_random_engine generator;
std::bernoulli_distribution distribution(0.5);
int count=0; // count number of trues
for (int i=0; i<100000; ++i) if (distribution(generator)) ++count;
I am looking for a Python equivalent.