def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in range(len(v)):
print v[i]
v = []
load(v)
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
v.sort()
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
w = v
print_(v)
print_(w)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
v.sort()
print_(v)
print "v.front() = " + v[0]
print "v.back() = " + v.pop(-1)
print "v.back() = " + v.pop(-1)
print "v.back() = " + v[-1]
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
v.sort()
print_(v)
v.pop(2) # removes Italy
v.pop(-2) # removes Spain
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
def print_(v):
for i in v:
print i
v = []
load(v)
v.sort()
print_(v)
r = []
for i in range(2,len(v)-2):
r.append(v[i]) #removes the segment Italy..Nepal
for i in r:
v.remove(i)
print_(v)
v.insert(2,"India")
print_(v)
def load(v):
v.append("Japan")
v.append("Italy")
v.append("Spain")
v.append("Egypt")
v.append("Chile")
v.append("Zaire")
v.append("Nepal")
v.append("Kenya")
v.append("India")
v.append("China")
v.append("Malta")
v.append("Syria")
def print_(v):
for i in v:
print i
v = []
load(v)
print_(v)
egypt = v.index('Egypt')
malta = v.index('Malta')
w = v[egypt:malta+1]
w.sort()
print_(w)
def copy(v,x,n):
for i in x:
v.append(i)
def projection(v,b):
v_size = len(v)
w = []
for i in range(0,v_size):
if b[i]:
w.append(v[i])
return w
def print_(v):
for i in v:
print i,
print ''
x = [ 22.2, 33.3, 44.4, 55.5, 66.6, 77.7, 88.8, 99.9 ]
v = []
copy(v, x, 8)
y = [ False, True, False, True, True, True, False, True ]
b = []
copy(b, y, 8)
w = projection(v, b)
print_(v)
print_(w)