Question: I want to implement the following Matlab code in Python:

```
x=1:100;
y=20*log10(x);

```

I tried using Numpy to do this:

```
y = numpy.zeros(x.shape)
for i in range(len(x)):
    y[i] = 20*math.log10(x[i])

```

But this uses a for loop; is there anyway to do a vectorized operation like in Matlab? I know for some simple math such as division and multiplication, it's possible. But what about other more sophisticated operations like logarithm here?

Answer: 
Yep, there certainly is.

```
x = numpy.arange(1, 100)
y = 20 * numpy.log10(x)

```
If you're not trying to do anything complicated, the original code could be implemented this way as well, without requiring the use of numpy, if I'm not mistaken.

```
>>> import math
>>> x = range(1, 101)
>>> y = [ 20 * math.log10(z) for z in x ]

```