# Quantum Coin Toss

## An easy-to-perform quantum mechanics-based alternative to tossing a coin

`import chancesimport random# use pseudo randomness to pick either even or oddrandom.choice(['even', 'odd'])# use pseudo randomness to pick either head or tailrandom.choice(['heads', 'tails'])# set the `max` and `n` values for the random generatorrand = chances.Randomizer(1000000, 1)# use quantum mechanical randomness to pick a numberrand.quantum()`
`def quantum_coin_toss(a, b):        '''Quantum coin tosser    a | str or int or list or dict | any value or set of values    b | str or int or list or dict | any value or set of values        '''        import chances    import random        # use pseudo randomness to pick either even or odd    even_or_odd = random.choice(['even', 'odd'])        # use pseudo randomness to pick either head or tail    a_or_b = random.choice([a, b])        # set the `max` and `n` values for the random generator    rand = chances.Randomizer(1000000, 1)        # use quantum mechanical randomness to pick a number    quantum_random_number = rand.quantum()        # handle the case where quantum random number is even    if quantum_random_number % 2 == 0:                if even_or_odd == 'even' and a_or_b == a:            return a                elif even_or_odd == 'even' and a_or_b == b:            return b                elif even_or_odd == 'odd' and a_or_b == a:            return b                elif even_or_odd == 'odd' and a_or_b == b:            return a            if quantum_random_number % 2 != 0:                if even_or_odd == 'even' and a_or_b == a:            return b                elif even_or_odd == 'even' and a_or_b == b:            return a                elif even_or_odd == 'odd' and a_or_b == a:            return a                elif even_or_odd == 'odd' and a_or_b == b:            return b`

--

--