Python Implementation of an Array Divided by a Number Example
- 2021-07-24 11:18:54
- OfStack
If you divide 1 list of python directly by 1 number, an error will be reported:
a = [1.0, 1.0, 1.0]
c = a/3
print(c)
TypeError: unsupported operand type(s) for /: 'list' and 'int'
With Numpy, you can easily:
import numpy as np
a = np.array([1,1,1])
c = a/3
print(c)