The problems below are designed to help you learn about the control structures and type system of the Python language. Write Python code to solve each problem, place your solutions into a directory, compress the directory and submit it using the handin command. Your submission must be received by 8 AM on Tuesday, July 7th, 2009. The format for the handin command is:
handin.428.1 1 *
def change(x, y):
return y,x
def one():
a = (1, 2)
b = (3, 4)
t = a + b
print t
L = []
L[:] = t[:]
return L
def two():
L = [x for x in range(0,7)]
return L
def three():
print 'three'
def four():
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k, v in knights.iteritems():
print k, v
if __name__ == "__main__":
a = 17
b = 71
print change(a, b)
print a, b
print one();
print two();
print three();
four();
The list: [1, 1, 1, 4, 4, 4, 5, 6, 7, 8, 8, 9, 11, 13, 14, 14, 15, 15, 18, 21, 22, 23, 23, 24, 25, 26, 30, 31, 32, 32, 33, 36, 36, 37, 38, 39, 40, 40, 43, 44, 44, 45, 48, 49, 51, 57, 57, 58, 58, 58, 58, 61, 61, 61, 62, 62, 63, 63, 64, 64, 65, 66, 67, 69, 69, 69, 69, 70, 70, 70, 72, 72, 72, 74, 76, 76, 78, 78, 78, 78, 78, 79, 80, 80, 82, 82, 82, 83, 84, 84, 86, 86, 88, 91, 92, 93, 94, 94, 94, 97] There are 100 duplicates 1: * * * 4: * * * 5: * 6: * 7: * 8: * * 9: * 11: * 13: * 14: * * 15: * * 18: * 21: * 22: * 23: * * 24: * 25: * 26: * 30: * 31: * 32: * * 33: * 36: * * 37: * 38: * 39: * 40: * * 43: * 44: * * 45: * 48: * 49: * 51: * 57: * * 58: * * * * 61: * * * 62: * * 63: * * 64: * * 65: * 66: * 67: * 69: * * * * 70: * * * 72: * * * 74: * 76: * * 78: * * * * * 79: * 80: * * 82: * * * 83: * 84: * * 86: * * 88: * 91: * 92: * 93: * 94: * * * 97: * Without dupes: [1, 4, 5, 6, 7, 8, 9, 11, 13, 14, 15, 18, 21, 22, 23, 24, 25, 26, 30, 31, 32, 33, 36, 37, 38, 39, 40, 43, 44, 45, 48, 49, 51, 57, 58, 61, 62, 63, 64, 65, 66, 67, 69, 70, 72, 74, 76, 78, 79, 80, 82, 83, 84, 86, 88, 91, 92, 93, 94, 97]