sum = 0
x = 1
n = 1
while True:
sum=sum+x
if n >=20:
break
n=n+1
x=x*2
print sum
x = 1
n = 1
while True:
sum=sum+x
if n >=20:
break
n=n+1
x=x*2
print sum
2018-05-16
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2 ==0:
continue
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2 ==0:
continue
sum+=x
print sum
2018-05-16
慕课版本为2.7 习惯3以上的版本输出要加括号
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print ("Adam:",d['Adam'])
print ("Lisa:",d.get('Lisa'))
print ("Bart:",d['Bart'])
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print ("Adam:",d['Adam'])
print ("Lisa:",d.get('Lisa'))
print ("Bart:",d['Bart'])
2018-05-16
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum=0.0
for key,value in d.items():
print key +':'+str(d.get(key))
sum=sum++d.get(key)
print sum/len(d)
sum=0.0
for key,value in d.items():
print key +':'+str(d.get(key))
sum=sum++d.get(key)
print sum/len(d)
2018-05-16
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
score=d.values()
sum=0.0
for i in score:
sum=sum+i
print sum/len(score)
score=d.values()
sum=0.0
for i in score:
sum=sum+i
print sum/len(score)
2018-05-16
# encoding:utf-8
s='abc'
news=s[:1].upper()+s[1:]
print news
s='abc'
news=s[:1].upper()+s[1:]
print news
2018-05-16