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-03-14
python函数返回多值返回的其实是一个tuple, 但是语法上,返回一个tuple可以省略括号,而多个变量可以同时接受一个tuple,按位置赋给相应的值。
2015-03-14
dict means dictionary in python, it's a kind of data structure! check it out here https://docs.python.org/2/tutorial/datastructures.html
2015-03-14
这题的判定有BUG,使用下面代码也可以通过
sum = 0
x = 1
while x <= 100:
sum += x%2==1
x+=1
print sum
sum = 0
x = 1
while x <= 100:
sum += x%2==1
x+=1
print sum
2015-03-13