L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[2]
正确答案,可以得经验。
print L[0]
print L[1]
print L[2]
print L[2]
正确答案,可以得经验。
2015-09-09
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum += x
n += 1
x = 2**(n-1)
print sum
x = 1
n = 1
while True:
if n > 20:
break
sum += x
n += 1
x = 2**(n-1)
print sum
2015-09-09
L = []
for m in '123456789':
for n in '0123456789':
for j in '123456789':
if m == j:
L.append(int(m+n+j))
print L
print [100*m + 10*n + m for m in range(1,10) for n in range (0,10)]
for m in '123456789':
for n in '0123456789':
for j in '123456789':
if m == j:
L.append(int(m+n+j))
print L
print [100*m + 10*n + m for m in range(1,10) for n in range (0,10)]
2015-09-08
1.为了能正常显示中文,在字符串前加u,例如:
u '中文'
u'''第一行
第二行'''
2.raw字符串仍然成立
ur'''"第一行"
第二行'''
3.用notepad++编写代码时,出现错误UnicodeDecodeError,解决办法在第一行添加:
# -*- coding: utf-8 -*-
u '中文'
u'''第一行
第二行'''
2.raw字符串仍然成立
ur'''"第一行"
第二行'''
3.用notepad++编写代码时,出现错误UnicodeDecodeError,解决办法在第一行添加:
# -*- coding: utf-8 -*-
2015-09-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d.get('Lisa')
if 'Bart' in d:
print 'Bart:',d["Bart"]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d.get('Lisa')
if 'Bart' in d:
print 'Bart:',d["Bart"]
2015-09-08
print [int(x+y+j) for x in '123456789' for y in '0123456789' for j in '123456789' if x==j]
2015-09-08
def generate_tr(name, score):
if score<60:
tdscore='<td style="color:red">%s' % score
else:
tdscore='<td>%s' % score
return '<tr><td>%s</td>%s</td></tr>' % (name, tdscore)
if score<60:
tdscore='<td style="color:red">%s' % score
else:
tdscore='<td>%s' % score
return '<tr><td>%s</td>%s</td></tr>' % (name, tdscore)
2015-09-08
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2015-09-08