s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for name in L:
if name in s:
s.remove(name)
else:
s.add(name)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for name in L:
if name in s:
s.remove(name)
else:
s.add(name)
print s
2018-07-04
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0],':',x[1]
for x in s:
print x[0],':',x[1]
2018-07-04
months = set(['Jan','Feb','Mar','Apr','May','Jun','Jul',
'Aug','Sep','Oct','Nov','Dec'])
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'
'Aug','Sep','Oct','Nov','Dec'])
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'
2018-07-04
s = set(['Adam', 'Lisa', 'Bart', 'Paul','adam','bart'])
print 'adam' in s
print 'bart' in s
print 'adam' in s
print 'bart' in s
2018-07-04
s = set(['Adam','Lisa','Bart','Paul'])
2018-07-04
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
2018-07-04
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d[72]='Paul'
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d[72]='Paul'
2018-07-04
# -*- coding: utf-8 -*-
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
2018-07-04
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+ str(d['Adam'])
print 'Lisa:'+str(d['Lisa'])
print 'Bart:'+str(d['Bart'])
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+ str(d['Adam'])
print 'Lisa:'+str(d['Lisa'])
print 'Bart:'+str(d['Bart'])
2018-07-04
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 2,3,4,5,6,7,8,9 ]:
if x < y:
print(str(x)+str(y))
else:
continue
for y in [ 2,3,4,5,6,7,8,9 ]:
if x < y:
print(str(x)+str(y))
else:
continue
2018-07-04
sum = 0
x = 0
while True:
x = x + 1
if x >= 100:
break
if not x%2:
continue
else:
sum+=x
print sum
x = 0
while True:
x = x + 1
if x >= 100:
break
if not x%2:
continue
else:
sum+=x
print sum
2018-07-04
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x % 2 == 0:
continue
else:
sum +=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x % 2 == 0:
continue
else:
sum +=x
print sum
2018-07-04
sum = 0
x = 1
n = 1
while True:
sum += x
x =2**n
n = n+1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum += x
x =2**n
n = n+1
if n > 20:
break
print sum
2018-07-04
sum = 0
x = 1
n = 1
while True:
sum+=x
x=x*2
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum+=x
x=x*2
n=n+1
if n>20:
break
print sum
2018-07-03