def average(*args):
if len(args)!=0:
s=sum(args)*1.0/len(args)
return s
else:
return 0
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args)!=0:
s=sum(args)*1.0/len(args)
return s
else:
return 0
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-04-11
def greet(x='world'):
print 'hello,'+ x+'.'
greet()
greet('bart')
print 'hello,'+ x+'.'
greet()
greet('bart')
2019-04-11
写的笔记刚才出去看缩进没有了,好在我还有一点没写完。
这一节不会的可以加我qq2211726672,备注汉诺塔就好。(限前3个,费曼学习法,当你可以教会别人时你难道还不会吗?1教3,3教9。哇好像干了件大事
这一节不会的可以加我qq2211726672,备注汉诺塔就好。(限前3个,费曼学习法,当你可以教会别人时你难道还不会吗?1教3,3教9。哇好像干了件大事
2019-04-11
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
print s
print s
2019-04-10
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key+':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key+':',d[key]
2019-04-10
for x in range(1,10):
for y in range(0,10):
if y>x:
print x*10+y
for y in range(0,10):
if y>x:
print x*10+y
2019-04-10
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2==0:
continue
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2==0:
continue
sum+=x
print sum
2019-04-10
sum = 0
x = 1
n = 1
while True:
if n>20:
break
sum+=x
n+=1
x<<=1
print sum
x = 1
n = 1
while True:
if n>20:
break
sum+=x
n+=1
x<<=1
print sum
2019-04-10
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
2019-04-10
L = [75, 92, 59, 68]
sum = 0.0
for a in L:
sum+=a
print sum / 4
sum = 0.0
for a in L:
sum+=a
print sum / 4
2019-04-10
def sum(L):
sum = 0
for x in L:
sum = x*x + sum
return sum
L=range(0,101)
print (sum(L))
sum = 0
for x in L:
sum = x*x + sum
return sum
L=range(0,101)
print (sum(L))
2019-04-10
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print(x[0]+':'+str(x[1]))
for x in s:
print(x[0]+':'+str(x[1]))
2019-04-10