d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print('%s:%d'%(key,d[key]))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print('%s:%d'%(key,d[key]))
2015-05-18
#Enter a code
print 45678+0x12fd2
print'Learn Python in imooc'
print 100<99
print 0xff==255
print 45678+0x12fd2
print'Learn Python in imooc'
print 100<99
print 0xff==255
2015-05-17
第一句,a非空,根据短路原则or运算直接输出a,而后面的b是空的字符串,所以做or运算时取决于后面的字符串,进而直接输出后面的字符串
2015-05-17
def average(*args):
sum = 0.0
n = len(args)
if n ==0:
return sum
for i in args:
sum +=i
avg = sum/len(args)
return avg
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
n = len(args)
if n ==0:
return sum
for i in args:
sum +=i
avg = sum/len(args)
return avg
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2015-05-17
def square_of_sum(L):
sum = 0
for x in L:
sum += x**2
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum = 0
for x in L:
sum += x**2
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-05-17