# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2018-05-14
print (45678 + 0x12fd2 )
print ("Learn Python in imooc")
print(100<99)
print(0xff == 255)
print ("Learn Python in imooc")
print(100<99)
print(0xff == 255)
2018-05-14
def square_of_sum(L):
x=0
for i in L:
x=i*i+x
return x
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
x=0
for i in L:
x=i*i+x
return x
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-13
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
2018-05-13
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]
2018-05-13
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/(len(d))
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/(len(d))
2018-05-13
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for i in d.values():
sum = sum+i
print sum/(len(d)*1.0)
sum = 0.0
for i in d.values():
sum = sum+i
print sum/(len(d)*1.0)
2018-05-13
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key+':'+str(d.get(key))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key+':'+str(d.get(key))
2018-05-13
a = ''
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:
a = str(x)+str(y)
else:
continue
print a
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:
a = str(x)+str(y)
else:
continue
print a
2018-05-13
在命令提示符中运行,有# -*- coding: utf-8 -*-,然后print u''' '''才显示正常。不用u的话显示乱码
2018-05-13
for x in range(1,10):
for y in range(1,10):
if x<y:
print x*10+y
for y in range(1,10):
if x<y:
print x*10+y
2018-05-13