d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59,
'paul': 75
}
print d['paul'] #原来通过名字查分数是这样写,卧槽,我感觉我是摸着石头过河,蒙出来的,老师都没教怎么查
'Adam': 95,
'Lisa': 85,
'Bart': 59,
'paul': 75
}
print d['paul'] #原来通过名字查分数是这样写,卧槽,我感觉我是摸着石头过河,蒙出来的,老师都没教怎么查
2018-06-19
for x in range(10):
for y in range(10):
if x < y:
print x * 10 + y
for y in range(10):
if x < y:
print x * 10 + y
2018-06-18
for x in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
for y in range(10):
if x < y:
print x * 10 + y
for y in range(10):
if x < y:
print x * 10 + y
2018-06-18
跟答案比,我还是不够偷懒啊。
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print d.values()
sum = 0.0
for a in d.values():
sum=sum+a
s=sum/len(d)
print s
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print d.values()
sum = 0.0
for a in d.values():
sum=sum+a
s=sum/len(d)
print s
2018-06-18
这个真的是我的骚操作,不过对我这种小白来说,答案里面突然出现第二个参数还真不知道是啥意思。
L = range(1, 101)
A=[]
for x in L:
if x<=50:
A.append(x)
print L[:10]
print L[2::3]
print A[4::5]
L = range(1, 101)
A=[]
for x in L:
if x<=50:
A.append(x)
print L[:10]
print L[2::3]
print A[4::5]
2018-06-18
>>> L = ['Adam, 95.5, Lisa, 85, Bart, 59']
>>> print(L)
['Adam, 95.5, Lisa, 85, Bart, 59']
>>> print(L)
['Adam, 95.5, Lisa, 85, Bart, 59']
2018-06-17
>>> classmates = ['Michael, Bob, Tracy']
>>> print(classmates)
['Michael, Bob, Tracy']
>>> L = ['Michael, 100, True']
>>> empty_list = []
>>> print(classmates)
['Michael, Bob, Tracy']
>>> L = ['Michael, 100, True']
>>> empty_list = []
2018-06-17
>>> 1 + 2 + 3
6
>>> 4 * 5 - 6
14
>>> 7.5 / 8 + 2.1
3.0375
>>> (1 + 2) * 3
9
>>> (2.2 + 3.3) / (1.5 * (9 - 0.3))
0.42145593869731807
>>> 1 + 2
3
>>> 1.0 + 2.0
3.0
>>> 1 + 2.0
3.0
>>> 11 / 3
3.6666666666666665
>>> 11 / 4
2.75
>>> 11 % 4
3
>>> 2.5 + 10 / 4
5.0
>>> 2.5 + 10.0 / 4
5.0
>>> 10 / 4
2.5
6
>>> 4 * 5 - 6
14
>>> 7.5 / 8 + 2.1
3.0375
>>> (1 + 2) * 3
9
>>> (2.2 + 3.3) / (1.5 * (9 - 0.3))
0.42145593869731807
>>> 1 + 2
3
>>> 1.0 + 2.0
3.0
>>> 1 + 2.0
3.0
>>> 11 / 3
3.6666666666666665
>>> 11 / 4
2.75
>>> 11 % 4
3
>>> 2.5 + 10 / 4
5.0
>>> 2.5 + 10.0 / 4
5.0
>>> 10 / 4
2.5
2018-06-17
>>> print('''第一行
... 第二行''')
第一行
第二行
>>> print(r'''Python的Unicode字符支持"中文","日文",
... "韩文"等多种语言''')
Python的Unicode字符支持"中文","日文",
"韩文"等多种语言
>>> # _*_ coding: utf-8 _*_
...
>>> print('''静夜思
... 床前明月光
... 疑是地上霜
... 举头望明月
... 低头思故乡''')
静夜思
床前明月光
疑是地上霜
举头望明月
低头思故乡
... 第二行''')
第一行
第二行
>>> print(r'''Python的Unicode字符支持"中文","日文",
... "韩文"等多种语言''')
Python的Unicode字符支持"中文","日文",
"韩文"等多种语言
>>> # _*_ coding: utf-8 _*_
...
>>> print('''静夜思
... 床前明月光
... 疑是地上霜
... 举头望明月
... 低头思故乡''')
静夜思
床前明月光
疑是地上霜
举头望明月
低头思故乡
2018-06-17
不加括号会报错的
>>> print (r'''"To be, or not to be":that is the question.
... Whether it's nobler in the mind to suffer.''')
"To be, or not to be":that is the question.
Whether it's nobler in the mind to suffer.
>>> print (r'''"To be, or not to be":that is the question.
... Whether it's nobler in the mind to suffer.''')
"To be, or not to be":that is the question.
Whether it's nobler in the mind to suffer.
2018-06-17