Generate 7 integers with equal probability from a function which returns 1/0 with probability p and (1-p)

Free for the first 3 answer contributors

Interview question asked to Data Scientists interviewing at Mastercard, Microsoft, NerdWallet and others: Generate 7 integers with equal probability from a function which returns 1/0 with probability p and (1-p).