d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for x in d.itervalues():
sum += x
print sum / len(d)
sum = 0.0
for x in d.itervalues():
sum += x
print sum / len(d)
2015-07-30
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
c = 0
for a in L:
c = 0
for b in s:
if a == b:
c = 1
if c == 0:
s.add(a)
else : s.remove(a)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
c = 0
for a in L:
c = 0
for b in s:
if a == b:
c = 1
if c == 0:
s.add(a)
else : s.remove(a)
print s
2015-07-30
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
2015-07-30
sum = 0
x = 1
n = 1
while True:
sum += n
n *= 2
x += 1
if x>20:break
print sum
x = 1
n = 1
while True:
sum += n
n *= 2
x += 1
if x>20:break
print sum
2015-07-30
sum = 0
x = 1
while x <= 100:
if x /2 != 0:
sum += x
x += 1
print sum
x = 1
while x <= 100:
if x /2 != 0:
sum += x
x += 1
print sum
2015-07-30
age = 20
if age >= 6 and age <18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
if age >= 6 and age <18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
2015-07-30
L = ['Adam', 'Lisa', 'Bart']
A = L[0]
L[0] = L[2]
L[2] = A
print L
A = L[0]
L[0] = L[2]
L[2] = A
print L
2015-07-30
# -*- coding: utf-8 -*-
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2015-07-29
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-07-29