def _xml_encode_email_char_at_random(ch):
    r = random()
    # Roughly 10% raw, 45% hex, 45% dec.
    # '@' *must* be encoded. I [John Gruber] insist.
    # Issue 26: '_' must be encoded.
    if r > 0.9 and ch not in "@_":
        return ch
    elif r < 0.45:
        # The [1:] is to drop leading '0': 0x63 -> x63
        return hex(ord(ch))[1:] % '&#%s;'
    else:
        return '&#%s;' % ord(ch)



#---- mainline
dataset/ETHPy150Open an0/Letterpress/code/markdown2/lib/markdown2.py/_xml_encode_email_char_at_random/swapped operands of `%`