10W -python
计算2 3 4 加运算符 小于30
>>> new=[''.join(('2',op,'3')) for op in ops]
>>> print(new)
['2+3', '2-3', '2*3', '2/3', '23']
>>> new=[''.join(('2',op,'3',op,'4')) for op in ops]
>>> print(new)
['2+3+4', '2-3-4', '2*3*4', '2/3/4', '234']
>>> new=[]
>>> for op1 in ops:
for op2 in ops:
new1=''.join(('2',op1,'3',op2,'4'))
new.append(new1)
print(new)
len(new)
['234', '23+4', '23-4', '23*4', '23/4']
5
['234', '23+4', '23-4', '23*4', '23/4', '2+34', '2+3+4', '2+3-4', '2+3*4', '2+3/4']
10
['234', '23+4', '23-4', '23*4', '23/4', '2+34', '2+3+4', '2+3-4', '2+3*4', '2+3/4', '2-34', '2-3+4', '2-3-4', '2-3*4', '2-3/4']
15
['234', '23+4', '23-4', '23*4', '23/4', '2+34', '2+3+4', '2+3-4', '2+3*4', '2+3/4', '2-34', '2-3+4', '2-3-4', '2-3*4', '2-3/4', '2*34', '2*3+4', '2*3-4', '2*3*4', '2*3/4']
20
['234', '23+4', '23-4', '23*4', '23/4', '2+34', '2+3+4', '2+3-4', '2+3*4', '2+3/4', '2-34', '2-3+4', '2-3-4', '2-3*4', '2-3/4', '2*34', '2*3+4', '2*3-4', '2*3*4', '2*3/4', '2/34', '2/3+4', '2/3-4', '2/3*4', '2/3/4']
>>> new=[]
>>> for op1 in ops:
for op2 in ops:
new1=''.join(('2',op1,'3',op2,'4'))
if eval(new1)<30:
new.append(new1)
>>> print(new)
['23+4', '23-4', '23/4', '2+3+4', '2+3-4', '2+3*4', '2+3/4', '2-34', '2-3+4', '2-3-4', '2-3*4', '2-3/4', '2*3+4', '2*3-4', '2*3*4', '2*3/4', '2/34', '2/3+4', '2/3-4', '2/3*4', '2/3/4']
```
专注数据分析
欢迎转载并注明出处
```