def average(*args):
sum=0.0
if len(args)==0:
return sum
for x in args:
sum=sum+x
return sum/len(args)
sum=0.0
if len(args)==0:
return sum
for x in args:
sum=sum+x
return sum/len(args)
2019-05-01
L = []
x=1
while True:
L.append(x*x)
x+=1
if x>100:
break
print sum(L)
x=1
while True:
L.append(x*x)
x+=1
if x>100:
break
print sum(L)
2019-05-01
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0]+':',x[1]
for x in s:
print x[0]+':',x[1]
2019-05-01
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-05-01
t = ('a', 'b', ('A', 'B'))
print t
print t
2019-05-01
16进制转10进制,在这里复习下,大家按葫芦画瓢
例:2AF5换算成10进制:
用竖式计算:
第0位: 5 * 16^0 = 5
第1位: F * 16^1 = 240
第2位: A * 16^2= 2560
第3位: 2 * 16^3 = 8192
例:2AF5换算成10进制:
用竖式计算:
第0位: 5 * 16^0 = 5
第1位: F * 16^1 = 240
第2位: A * 16^2= 2560
第3位: 2 * 16^3 = 8192
2019-04-30
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
2019-04-28
s = set(['adam','bart'])
print 'adam' in s
print 'bart' in s
print 'adam' in s
print 'bart' in s
2019-04-26
sum = 0
x = 1
while x <= 100:
sum += x
x += 2
print sum
x = 1
while x <= 100:
sum += x
x += 2
print sum
2019-04-25