Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
0
Indexable
Never
print('calcu...  yk what it is')
def a(l, r):
    return l + r
def s(l, r):   #order-sensitive
    return l - r
def m(l, r):
    return l * r
def d(l, r):   #order-sensitive
    return l / r
l = input('first one ')
try:
    ll = float(l)
except:
    raise ValueError(f'add "{l}"? sub "{l}"? MuLtIpLy "{l}"? DIVIDE "{l}"?!')
r = input('second ')
try:
    rr = float(r)
except:
    raise ValueError(f'add "{r}"? sub "{r}"? MuLtIpLy "{r}"? DIVIDE "{r}"?!')
op = input('|a = add\n|s = subtract\n|m = multiply\n|d = divide\nwha? ')
if (op == 'a') or (op == 'A'):
    print(a(ll, rr))
elif (op == 's') or (op == 'S'):
    try:
        s = s(ll, rr)
        print('¡ORDER-SENSITIVE!')
        print(s)
    except:
        raise ZeroDivisionError('tryna play?')
elif (op == 'm') or (op == 'M'):
    print(m(ll, rr))
elif (op == 'd') or (op == 'D'):
    try:
        d = d(ll, rr)
        print('¡ORDER-SENSITIVE!')
        print(d)
    except:
        raise ZeroDivisionError('tryna play?')
else:
    raise NameError(f'what on earth is "{op}"')
Leave a Comment