Date: December 10, 2013
Time: 14:10-16:00
Open book; turn off computer & mobile phone
# Pass by Value
def ChangeList( a ):
a[0] = 10
def append(a):
a[0]=5
a = a + [2]
lstFoo = [2]
ChangeList(lstFoo )
print(lstFoo)
append(lstFoo)
print(lstFoo)
# Modifying a List
aList = [0] * 6
sequence = [1, 2, 3, 4, 5, 1, 3, 5]
for i in sequence.split():
aList[i] = aList[i] + 1
for i in aList:
print(i, end=' ')
# Loop Structure sum = 0
for i in range(10): sum = sum + i
if i == 5: break
print(i)
print(sum)