d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in ['Adam', 'Lisa', 'Bart']:
print i + ': ' + str(d[i])
print i + ':',d[i]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in ['Adam', 'Lisa', 'Bart']:
print i + ': ' + str(d[i])
print i + ':',d[i]
2015-03-04
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print '%s:%s'%(x[0],x[1])
for x in s:
print '%s:%s'%(x[0],x[1])
2015-03-04
扩展下
months = set(['Jan','Feb'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print '%s:ok'%x1
months = set(['Jan','Feb'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print '%s:ok'%x1
2015-03-04
我来给大家想要的答案。。。
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
for i in s:
if i.lower() == 'adam'.lower():
print 'Ture'
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
for i in s:
if i.lower() == 'adam'.lower():
print 'Ture'
2015-03-04
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in d:
print i,':',d.get(i)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in d:
print i,':',d.get(i)
2015-03-04
for x in ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
for y in ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
for y in ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
2015-03-04
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in d:
if d.get(i) == 95:
print i
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for i in d:
if d.get(i) == 95:
print i
2015-03-04
sum = 0
x = 1
while True:
if x > 100:
break
else:
sum +=x
x += 2
print sum
x = 1
while True:
if x > 100:
break
else:
sum +=x
x += 2
print sum
2015-03-04
sum = 0
x = 1
n = 1
while True:
sum+=x
x=2**n
n+=1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum+=x
x=2**n
n+=1
if n>20:
break
print sum
2015-03-04
x = 1
d = 3
n=1
s=0
while n<= 100 :
s += x
x += d
n += 1
print s
d = 3
n=1
s=0
while n<= 100 :
s += x
x += d
n += 1
print s
2015-03-04
print('hello,python')
print('hello,python')
print('hello,python')
2015-03-04