d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for x in d :
print x,':',d.get(x)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for x in d :
print x,':',d.get(x)
2016-11-12
score = 75
if score>=60:
print 'passed'
print 'failed'
if score>=60:
print 'passed'
print 'failed'
2016-11-12
对已有的计算 0 - 100 的while循环进行改造,通过增加 continue 语句,使得只计算奇数的和: 问的是奇数的和为什么答案是计算偶数的和?求解?
2016-11-12
s = []
L = list(range(1, 101))
for x in L:
s.append(x*x)
print sum(s)
L = list(range(1, 101))
for x in L:
s.append(x*x)
print sum(s)
2016-11-12
print r'''"to be,or not to be":that is the question.Whether it's nobler in the mind to suffer.'''
2016-11-12
#-*- coding: utf-8 -*-
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
for i in d:
if i == 95: #找到dict里面key的值为95的那个
print d[i]
#按照dict中的key来定位value感觉这样子的判断更加符合我们初学者的习惯。
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
for i in d:
if i == 95: #找到dict里面key的值为95的那个
print d[i]
#按照dict中的key来定位value感觉这样子的判断更加符合我们初学者的习惯。
2016-11-12
s = 'Python was started in 1989 by \"Guido\".\nPython is free and easy to learn.'
2016-11-12