Convert Roman Numerals to integers
Dict initialization and reuse
This:
ref = dict()                                                                                
ref['I'] = 1
ref['V'] = 5
ref['X'] = 10
ref['L'] = 50
ref['C'] = 100
ref['D'] = 500
ref['M'] = 1000

should use a dict literal:
ref = {
    'I': 1,
    'V': 5,
    'X': 10,
    'L': 50,
    'C': 100,
    'D': 500,
    'M': 1000,
}

You should declare this at the top of the program, so that this:
'[^IVXLCDM]+'

can become
'[^' + ''.join(ref.keys()) + ']+'

and this
'Roman Numerals may contain only the characters I, V, X, L, C, D, M'

can become
'Roman Numerals may contain only the characters ' + ', '.join(ref.keys())

No-op continue
This:
    else:
        continue

has no effect and can be deleted.
Booleans
bad should use True and False rather than 1 and 0.