def a(x,y,z):
s=x*(1-y**z)/(1-y)
return s
print(a(1,2,20))
s=x*(1-y**z)/(1-y)
return s
print(a(1,2,20))
2019-09-27
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print d.iteritems()
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
average = sum / len(d)
print 'average', ':', average
print d.iteritems()
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
average = sum / len(d)
print 'average', ':', average
2019-09-27
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print d.itervalues()
sum = 0.0
for x in d.itervalues():
print x
sum += x
print sum / len(d)
print d.itervalues()
sum = 0.0
for x in d.itervalues():
print x
sum += x
print sum / len(d)
2019-09-27
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print d.itervalues()
n = 0
sum = 0.0
for x in d.itervalues():
print x
n += 1
sum += x
print sum / n
print d.itervalues()
n = 0
sum = 0.0
for x in d.itervalues():
print x
n += 1
sum += x
print sum / n
2019-09-27
L = []
x=1
while x<=100:
x=x+1
L.append(x*x)
print sum(L)
我想知道我这种和答案的区别在哪里
x=1
while x<=100:
x=x+1
L.append(x*x)
print sum(L)
我想知道我这种和答案的区别在哪里
2019-09-26
sum = 0
x = 1
n = 1
while True:
x=2**(n-1)
sum=sum+x
n+=1
if n>=21 :
break
print sum
x = 1
n = 1
while True:
x=2**(n-1)
sum=sum+x
n+=1
if n>=21 :
break
print sum
2019-09-26
sum = 0
x = 1
while True:
sum+=x
x = x + 2
if x > 100:
break
print sum
x = 1
while True:
sum+=x
x = x + 2
if x > 100:
break
print sum
2019-09-26
sum = 0
x = 1
n = 1
while True:
sum+=x
x = x + 2
n = n + 2
if n > 100:
break
print sum
x = 1
n = 1
while True:
sum+=x
x = x + 2
n = n + 2
if n > 100:
break
print sum
2019-09-26
for x in [1,2,3,4,5,6,7,8,9]:
for y in [1,2,3,4,5,6,7,8,9]:
if x<y :
print x,y
for y in [1,2,3,4,5,6,7,8,9]:
if x<y :
print x,y
2019-09-26
score = 85
if score>=90:
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
if score>=90:
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
2019-09-26
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Paul')
print L
L.insert(2,'Paul')
print L
2019-09-26