sum = 0
x = 0
while x < 100:
sum = 2*x+1
x = 2*x+1
print sum
x = 0
while x < 100:
sum = 2*x+1
x = 2*x+1
print sum
2015-03-05
最新回答 / xnby
python 里 () 可以表示元组 tripe,在2.7优先解析成tripe类型了,(可以 type('hello,','python')测试),本地3.4优先认为是函数,python2.7和3.4版本有区别的
2015-03-05
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