months = set(['jan','Feb'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
2015-03-24
s = set(['adam','bart'])
print 'adam' in s
print 'bart' in s
print 'adam' in s
print 'bart' in s
2015-03-24
s = set(['Adam','Lisa','Bart','Paul'])
print s
print s
2015-03-24
def square_of_sum(L):
return sum([ x * x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
return sum([ x * x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-03-23
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print "%s: %s" %x
for x in s:
print "%s: %s" %x
2015-03-23
age = 20
if age < 6:
print 'kid'
elif age >= 18:
print 'adult'
else:
print 'teenager'
if age < 6:
print 'kid'
elif age >= 18:
print 'adult'
else:
print 'teenager'
2015-03-23