d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
if 'Adam' in d:
print d['Adam']
print d.get('Lisa')
print d['Bart']
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
if 'Adam' in d:
print d['Adam']
print d.get('Lisa')
print d['Bart']
2015-12-04
a = 0
sum = 0
while a < 100:
if a % 2 == 1:
sum = sum + a
a = a + 1
print sum
sum = 0
while a < 100:
if a % 2 == 1:
sum = sum + a
a = a + 1
print sum
2015-12-03
BREAK语句:
sum=0
x = 1
while True:
sum = sum + x
x = x + 2
if x > 100 :
break
print sum
continue语句:
sum = 0
x = 0
while True:
x = x + 1
if x > 100 :
break
if x % 2 == 0 :
continue
sum = sum + x
print sum
sum=0
x = 1
while True:
sum = sum + x
x = x + 2
if x > 100 :
break
print sum
continue语句:
sum = 0
x = 0
while True:
x = x + 1
if x > 100 :
break
if x % 2 == 0 :
continue
sum = sum + x
print sum
2015-12-03
Grade_test = 0
if Grade_test >= 60:
print 'passed'
else:
print 'Failed'
if Grade_test >= 60:
print 'passed'
else:
print 'Failed'
2015-12-03
#L_test = ['dengqing',100,'xiaohong',90]
#L_test.append('test')
#L_test.insert(1,'test')
#L_test.pop()
#L_test.pop(0)
#L_test[1]=120
T_test = (0,'a',[1,'test1'])
L_test = T_test[2]
L_test[0] = 'deng'
L_test[1] = 'qing'
print T_test
#L_test.append('test')
#L_test.insert(1,'test')
#L_test.pop()
#L_test.pop(0)
#L_test[1]=120
T_test = (0,'a',[1,'test1'])
L_test = T_test[2]
L_test[0] = 'deng'
L_test[1] = 'qing'
print T_test
2015-12-03
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s =(x1+x100)*n/2
print s
s=14950
d = 3
n = 100
x100 = x1+(n-1)*d
s =(x1+x100)*n/2
print s
s=14950
2015-12-03
print [a*100+b*10+c for a in range(1,10) for b in range(1,10) for c in range(1,10) if a==c]
2015-12-02