# Jeffrey Yuan
# Mission San
Jose High School
# Intermediate 3
def divide(cell):
return cell[:4] * 2, cell[4:] * 2
def add(cell,
number):
s = cell[:number] + cell
s = s[:8]
return s
def
subtract(cell, number):
return cell[number:] + cell[-number:]
def union(first,
second):
return first[4:] + second[:4]
def
intersect(first, second):
return first[:2] + first[6:] + second[:2]
+ second[6:]
for i in
range(5):
while True:
s = raw_input("Input number
" + str(i+1) + ": ")
for i in range(len(s)-1,-1,-1):
if not s[i].isalpha() and not
s[i].isdigit():
s = s[:i] + s[i+1:]
if s[0] == 'D':
t = divide(s[-8:])
print t[0] + " and "
+ t[1]
break
elif s[0] == 'A':
print add(s[-8:], int(s[3]))
break
elif
s[0] == 'S':
print subtract(s[-8:],
int(s[8]))
break
elif s[0] == 'U':
print union(s[-16:-8], s[-8:])
break
elif s[0] == 'I':
print intersect(s[-16:-8],
s[-8:])
break
else:
print "Unfortunately
that's not valid..."