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-04-17
# -*- coding: utf-8 -*-
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
s = 59
print d[s]
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
s = 59
print d[s]
2018-04-17
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for (key, value) in d.items():
print('%s:%s' %(key, value))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for (key, value) in d.items():
print('%s:%s' %(key, value))
2018-04-17
def greet(s='world'):
print 'hello',s
greet()
greet('Bart')
print 'hello',s
greet()
greet('Bart')
2018-04-17
for name in L:
if name in s:
s.remove(name)
else:
s.add(name)
if name in s:
s.remove(name)
else:
s.add(name)
2018-04-17
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-04-17
months = set(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'])
2018-04-17
def square_of_sum(L):
s=0
for x in L:
s=s+x*x
return s
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
s=0
for x in L:
s=s+x*x
return s
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-04-17
for x in range(1,10):
for y in [1,2,3,4,5,6,7,8,9]:
if x>=y:
continue
else:
print x,y
for y in [1,2,3,4,5,6,7,8,9]:
if x>=y:
continue
else:
print x,y
2018-04-16