0
Can we divide two lists in Py
3 Réponses
+ 3
Importing Numpy:
import numpy
Creating a Numpy array:
na1 = numpy.array([0, 2, 1, 5])
When you divide a Numpy array with a number you'll get a copy of the array, where each item has applied the operator:
na1 / 2
--->
numpy.array([0.0, 1.0, 0.5, 2.5])
You can also divide a numpy array with another equal sized array, where the items at the same indices are divided:
numpy.array([100]*4) / numpy.array([2, 4, 8, 16])
--->
numpy.array([50.0, 25.0, 12.5, 6.25])
+ 4
Describe your idea of "divide two lists" clearly, and specify a relevant language in your thread's tags. 'how' is not a proper word for tags, up there ☝
+ 1
I don't know, how you want to divide a list, but atleast Numpy arrays have some predefined methods for it.