d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for a in d:
print a,':',d.get(a)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for a in d:
print a,':',d.get(a)
2017-02-27
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for index, name in enumerate(L):
print index+1, '-', name
for index, name in enumerate(L):
print index+1, '-', name
for x in [ 1,2,3,4,5,6,7,8,9]:
for y in [ 0,1,2,3,4,5,6,7,8,9,]:
if y >x:
print x*10 + y
for y in [ 0,1,2,3,4,5,6,7,8,9,]:
if y >x:
print x*10 + y
2017-02-27
然而任务是用多行Unicode字符串,那还是要用u,然而# -*- coding: utf-8 -*-留着u删掉能过,u留着# -*- coding: utf-8 -*-删掉就不能过
2017-02-27
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
x = 2**(n-1)
sum = sum+x
n = n + 1
print sum
x = 1
n = 1
while True:
if n > 20:
break
x = 2**(n-1)
sum = sum+x
n = n + 1
print sum
2017-02-27
L = [95.5, 85, 59]
print 'the last one is: ' + str( L[-1] )
print 'the last but one is : ' + str( L[-2] )
print "the antepenultimate guy is : " + str( L[-3] )
print 'the last one is: ' + str( L[-1] )
print 'the last but one is : ' + str( L[-2] )
print "the antepenultimate guy is : " + str( L[-3] )
2017-02-27
x1 = (-b + math.sqrt(b ** 2 - 4 * a * c))/(2 * a)
x2 = (-b - math.sqrt(b ** 2 - 4 * a * c))/(2 * a)
return x1,x2
x2 = (-b - math.sqrt(b ** 2 - 4 * a * c))/(2 * a)
return x1,x2
2017-02-27