d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
if 72 in d:
d[72]=d[72],'Paul'
else:
d[72]='Paul'
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
if 72 in d:
d[72]=d[72],'Paul'
else:
d[72]='Paul'
2018-04-27
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
score=59
for i in d:
if d[i]==score:
print(i)
continue
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
score=59
for i in d:
if d[i]==score:
print(i)
continue
2018-04-27
for x in [1, 2, 3, 4, 5, 6, 7, 8] :
for y in [2, 3, 4, 5, 6, 7, 8, 9] :
if x >= y :
continue
print 10*x+y
for y in [2, 3, 4, 5, 6, 7, 8, 9] :
if x >= y :
continue
print 10*x+y
2018-04-27
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2018-04-27
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
2018-04-27
sum = 0
x = 1
while x<100:
sum=sum+x
x=x+2
print sum #注意45行要先空四格 最后的结果为2500才是正确
x = 1
while x<100:
sum=sum+x
x=x+2
print sum #注意45行要先空四格 最后的结果为2500才是正确
2018-04-27
sum = 0
x = 1
while x<100:
print x
x=x+1
sum=50*(1+99)/2
print sum
x = 1
while x<100:
print x
x=x+1
sum=50*(1+99)/2
print sum
2018-04-27
L = [75, 92, 59, 68]
sum = 0.0
for score in L :
sum = sum + score
print sum / 4
sum = 0.0
for score in L :
sum = sum + score
print sum / 4
2018-04-27
def square_of_sum(L):
result = 0
for a in L:
result = result + a*a
return result
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
result = 0
for a in L:
result = result + a*a
return result
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-04-26
#-*- coding:utf-8 -*-
sum = 0 #储存每次循环的家伙
x = 0 #递增,从1开始
while True: #一直循环下去,等屎吧
x = x + 1 #每次+1
if x > 100: #满100滚蛋
break #滚
if x % 2 == 0: #等0是偶数,绕过
continue #偶数死开
sum = sum + x #非偶数,叠加存储
print sum
sum = 0 #储存每次循环的家伙
x = 0 #递增,从1开始
while True: #一直循环下去,等屎吧
x = x + 1 #每次+1
if x > 100: #满100滚蛋
break #滚
if x % 2 == 0: #等0是偶数,绕过
continue #偶数死开
sum = sum + x #非偶数,叠加存储
print sum
2018-04-26
#-*- coding:utf-8 -*-
sum = 0
x = 1
n = 1
while True:
sum = sum + x #保存每次的x2
x = x * 2 #每次增加1倍
n = n + 1 #n是计数用的
if n > 20: #如果n超过20次退出
break
print 'sum的值是',sum
sum = 0
x = 1
n = 1
while True:
sum = sum + x #保存每次的x2
x = x * 2 #每次增加1倍
n = n + 1 #n是计数用的
if n > 20: #如果n超过20次退出
break
print 'sum的值是',sum
2018-04-26