最新回答 / 慕粉1127469790
Sets 模块提供了构建和处理独立对象的无序集合的类。该模块的通常使用包括成员测试、删除序列中的雍余对象,以及像求交、求并、作差和均差(symmetric difference)这些数学运算
2017-03-02
因为Python把0、空字符串''和None看成 False,其他数值和非空字符串都看成 True
2017-03-02
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print ('Adam:',d.get('Adam'))
print ('Lisa:',d['Lisa'])
if 'Bart' in d:
print('Bart:',d['Bart'])
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print ('Adam:',d.get('Adam'))
print ('Lisa:',d['Lisa'])
if 'Bart' in d:
print('Bart:',d['Bart'])
2017-03-02
可不可以这么想, dict外壳是一个list,所以拥有list可以修改的属性,而里面的Key-Value是一组tuple,不能修改,但能替换
2017-03-02
L=[]
for x in list(range(10)):
for y in list(range(10)):
if x==0:
continue
elif x < y:
L.append(x*10+y)
else:
continue
print(L)
报错 - -
for x in list(range(10)):
for y in list(range(10)):
if x==0:
continue
elif x < y:
L.append(x*10+y)
else:
continue
print(L)
报错 - -
2017-03-02
>>> import math
>>> def move(x,y,step,angle):
nx=x+step*math.cos(angle)
ny=y-step*math.sin(angle)
return nx,ny
>>> r=move(100,100,60,math.pi/6)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
r=move(100,100,60,math.pi/6)
NameError: name 'move' is not defined
求救!
>>> def move(x,y,step,angle):
nx=x+step*math.cos(angle)
ny=y-step*math.sin(angle)
return nx,ny
>>> r=move(100,100,60,math.pi/6)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
r=move(100,100,60,math.pi/6)
NameError: name 'move' is not defined
求救!
2017-03-01
x1 = 1
d = 3
n = 100
x100 = 1 +3*99
s = (x1 +x100)*50
print s
参考完其他同学的答案之后发现有几个变量都没用上,太马虎了
d = 3
n = 100
x100 = 1 +3*99
s = (x1 +x100)*50
print s
参考完其他同学的答案之后发现有几个变量都没用上,太马虎了
2017-03-01