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]
2015-06-09
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,":",d.get(k)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,":",d.get(k)
2015-06-08
# -*- coding: utf-8 -*-
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
print u'您的姓名是:',d.get(input)
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
print u'您的姓名是:',d.get(input)
2015-06-08
# -*- coding: utf-8 -*-
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
2015-06-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name in d:
print name,":",d.get(name)
Lisa : 85
Adam : 95
Bart : 59
就是得到的值排序好像很混乱
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name in d:
print name,":",d.get(name)
Lisa : 85
Adam : 95
Bart : 59
就是得到的值排序好像很混乱
2015-06-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
a = 'Adam'
b = 'Lisa'
c = 'Bart'
print a,":",d.get(a)
print b,":",d.get(b)
print c,":",d.get(c)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
a = 'Adam'
b = 'Lisa'
c = 'Bart'
print a,":",d.get(a)
print b,":",d.get(b)
print c,":",d.get(c)
2015-06-08
for x in [ 1,2,3,4,5,6,7,8]:
for y in [2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
for y in [2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
2015-06-08
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum = sum + x
print sum
2015-06-08
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
2015-06-08
sum = 0
x = 1
while x <= 100:
x = x + 2
sum = sum + x
print sum
x = 1
while x <= 100:
x = x + 2
sum = sum + x
print sum
2015-06-08
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
2015-06-08
score = 85
if score >=90:
print 'excellent'
elif score >=80:
print 'good'
elif score >=60:
print 'passed'
else:
print 'failed'
age = 8
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
if score >=90:
print 'excellent'
elif score >=80:
print 'good'
elif score >=60:
print 'passed'
else:
print 'failed'
age = 8
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
2015-06-08
L = ['Adam', 'Lisa', 'Bart']
L[0] = 'Bart'
L[-1] = 'Adam'
print L
L[0] = 'Bart'
L[-1] = 'Adam'
print L
2015-06-08